(0) exportieren Drucken
Alle erweitern


Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the property on this type.

Namespace: System.Windows
Assembly: WindowsBase (in windowsbase.dll)

public void CoerceValue (
	DependencyProperty dp
public void CoerceValue (
	DependencyProperty dp
public function CoerceValue (
	dp : DependencyProperty
Sie können diese Methoden nicht in XAML verwenden.



The identifier for the dependency property to coerce.



The specified dp or its value were invalid or do not exist.

The CoerceValueCallback is also invoked internally whenever a property value is being re-evaluated.

When you invoke the CoerceValue method, you are ultimately invoking the coerce value callback for the property that you specify. Typically you will only invoke CoerceValue if you know that a coerce value callback exists, and if you know the callback's criterion for coercion.

The most common scenario for calling CoerceValue is within class handling or property change callbacks of related properties that influence each other's values in a dependent way.

The following example calls CoerceValue within a PropertyChangedCallback implementation that is used as the PropertyChangedCallback for a different dependency properties on the same class. This is a common pattern for introducing true value dependencies between dependency properties.

private static void OnCurrentReadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.

.NET Framework

Unterstützt in: 3.0
© 2014 Microsoft