2

I'm trying to wrap my head around the difference between when PropertyChangedCallback is called and when CoerceValueCallback is called when setting up Dependency/Attached properties in WPF.

For example,

        public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached(
        "Value",
        typeof(TProperty),
        typeof(BaseAttachedProperty<TParent, TProperty>),
        new PropertyMetadata(default(TProperty),
        new PropertyChangedCallback(PropertyChanged),
        new CoerceValueCallback(CoerceCallback)));

if I have a dependency property called ValueProperty, which has a delegate PropertyChanged for PropertyChangedCallback, and delegate CoerceCallback for CoerceValueCallback, when are they called?

William Gao
  • 21
  • 1
  • 2
  • Explained here: https://learn.microsoft.com/en-us/dotnet/api/system.windows.coercevaluecallback?view=netframework-4.7.2#remarks – Clemens Dec 31 '18 at 15:05
  • Does this answer your question? [Difference between CoreceValueCallback and ValidateValueCallback?](https://stackoverflow.com/questions/17311144/difference-between-corecevaluecallback-and-validatevaluecallback) – StayOnTarget Apr 07 '20 at 18:04

0 Answers0