Wpf dependency property not updating
16-Mar-2020 15:24
There is nothing technically wrong with complex dependencies, but they can be a slight performance detriment if they require large numbers of reevaluations, and can also be confusing to users if they affect the UI directly.Be careful with property changed and coerce value callbacks and make sure that the coercion being attempted can be treated as unambiguously as possible, and does not "overconstrain".The Coerce Value Callback callbacks will be used by the property system to coerce a value in accordance to the logic you declare, but a coerced value of a locally set property will still retain a "desired value" internally.If the constraints are based on other property values that may change dynamically during the application lifetime, the coercion constraints are changed dynamically also, and the constrained property can change its value to get as close to the desired value as possible given the new constraints.Validation callbacks specifically are intended to be class validators, not instance validators.The parameters of the callback do not communicate a specific Dependency Object on which the properties to validate are set.This topic assumes that you understand the basic scenarios of implementing a dependency property, and how metadata is applied to a custom dependency property.See Custom Dependency Properties and Dependency Property Metadata for context.
The callbacks are used by the property system in a variety of different operations.
For instance, in the Min/Max/Current scenario, you could choose to have Minimum and Maximum be user settable.