DependencyObject.ClearValue Yöntem
Tanım
Bir özelliğin yerel değerini temizler.Clears the local value of a property.
Aşırı Yüklemeler
ClearValue(DependencyProperty) |
Bir özelliğin yerel değerini temizler.Clears the local value of a property. Temizlenme özelliği bir tanımlayıcı tarafından belirtilir DependencyProperty .The property to be cleared is specified by a DependencyProperty identifier. |
ClearValue(DependencyPropertyKey) |
Salt okunurdur özelliğinin yerel değerini temizler.Clears the local value of a read-only property. Temizlenme özelliği bir tarafından belirtilir DependencyPropertyKey .The property to be cleared is specified by a DependencyPropertyKey. |
ClearValue(DependencyProperty)
Bir özelliğin yerel değerini temizler.Clears the local value of a property. Temizlenme özelliği bir tanımlayıcı tarafından belirtilir DependencyProperty .The property to be cleared is specified by a DependencyProperty identifier.
public:
void ClearValue(System::Windows::DependencyProperty ^ dp);
public void ClearValue (System.Windows.DependencyProperty dp);
member this.ClearValue : System.Windows.DependencyProperty -> unit
Public Sub ClearValue (dp As DependencyProperty)
Parametreler
Bir nesne başvurusuyla tanımlanan, silinecek bağımlılık özelliği DependencyProperty .The dependency property to be cleared, identified by a DependencyProperty object reference.
Özel durumlar
ClearValue(DependencyProperty)Sealed üzerinde çağrılmaya çalışıldı DependencyObject .Attempted to call ClearValue(DependencyProperty) on a sealed DependencyObject.
Örnekler
Aşağıdaki örnek, bir nesnesinde yerel değerleri ayarlanmış tüm özellikleri yineler, ardından ClearValue Bu her bir özelliğin değerlerini temizlemek için çağırır.The following example iterates all properties that have local values set on an object, then calls ClearValue to clear the values of each such property.
void RestoreDefaultProperties(object sender, RoutedEventArgs e)
{
UIElementCollection uic = Sandbox.Children;
foreach (Shape uie in uic)
{
LocalValueEnumerator locallySetProperties = uie.GetLocalValueEnumerator();
while (locallySetProperties.MoveNext())
{
DependencyProperty propertyToClear = locallySetProperties.Current.Property;
if (!propertyToClear.ReadOnly) { uie.ClearValue(propertyToClear); }
}
}
}
Private Sub RestoreDefaultProperties(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim uic As UIElementCollection = Sandbox.Children
For Each uie As Shape In uic
Dim locallySetProperties As LocalValueEnumerator = uie.GetLocalValueEnumerator()
While locallySetProperties.MoveNext()
Dim propertyToClear As DependencyProperty = locallySetProperties.Current.Property
If Not propertyToClear.ReadOnly Then
uie.ClearValue(propertyToClear)
End If
End While
Next
End Sub
Açıklamalar
Özellik değerini çağırarak, bağımlılık özelliği ClearValue meta verilerinde belirtilen varsayılan değere bir bağımlılık özelliğine sahip değildir.Clearing the property value by calling ClearValue does not necessarily give a dependency property the default value that is specified in the dependency property metadata. Özelliği temizlemek yalnızca özel olarak uygulanmış olabilecek yerel değeri temizler.Clearing the property only specifically clears whatever local value may have been applied. Daha fazla bilgi için bkz. bağımlılık özelliği değer önceliği.For more information, see Dependency Property Value Precedence.
Ayrıca bkz.
Şunlara uygulanır
ClearValue(DependencyPropertyKey)
Salt okunurdur özelliğinin yerel değerini temizler.Clears the local value of a read-only property. Temizlenme özelliği bir tarafından belirtilir DependencyPropertyKey .The property to be cleared is specified by a DependencyPropertyKey.
public:
void ClearValue(System::Windows::DependencyPropertyKey ^ key);
public void ClearValue (System.Windows.DependencyPropertyKey key);
member this.ClearValue : System.Windows.DependencyPropertyKey -> unit
Public Sub ClearValue (key As DependencyPropertyKey)
Parametreler
Bağımlılık özelliğinin temizleneceği anahtar.The key for the dependency property to be cleared.
Özel durumlar
ClearValue(DependencyProperty)Sealed üzerinde çağrılmaya çalışıldı DependencyObject .Attempted to call ClearValue(DependencyProperty) on a sealed DependencyObject.
Açıklamalar
, DependencyPropertyKey Özellik sistemi işlemleri için salt okunurdur bir bağımlılık özelliği tanımlar.A DependencyPropertyKey identifies a read-only dependency property for property system operations. Salt okuma bağımlılığı özelliklerini tanımlayan sınıflar, bu anahtarı ortak erişimle göstermemelidir.Classes that define read-only dependency properties should not expose this key with public access. Genel olarak ortaya çıkan bir anahtar, özelliğinin salt okunurdur olan bir ortak kod patika sağlar, örneğin veya gibi yöntemler, ClearValue SetValue anahtara başvuruda bulunan sınıf veya derleme dışında çağrılabilir.A publicly exposed key would provide a public code pathway that negated the read-only character of the property, if methods such as ClearValue or SetValue could be called outside the class or assembly, referencing the key.
Özellik değerini çağırarak, bağımlılık özelliği ClearValue meta verilerinde belirtilen varsayılan değere bir bağımlılık özelliğine sahip değildir.Clearing the property value by calling ClearValue does not necessarily give a dependency property the default value that is specified in the dependency property metadata. Değerin temizlenmesi yalnızca yerel olarak uygulanan her türlü yerel değeri temizler.Clearing the value only specifically clears whatever local value may have been applied. Daha fazla bilgi için bkz. bağımlılık özelliği değer önceliği.For more information, see Dependency Property Value Precedence.