DependencyObject.CoerceValue Method
Assembly: WindowsBase (in windowsbase.dll)
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) { d.CoerceValue(MinReadingProperty); d.CoerceValue(MaxReadingProperty); }
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.