WPF DependencyProperty event before content changed

Posted by morsanu on Stack Overflow See other posts from Stack Overflow or by morsanu
Published on 2010-05-17T09:35:14Z Indexed on 2010/05/17 9:40 UTC
Read the original article Hit count: 320

Filed under:
|
|

First I will explain the context of the problem, because you might be able to point me in a better direction.

I need to implement a undo-redo like system on an object. The object has a series of dependency properties. Some are double, int, string but some are also of DependencyObject type. I need to save the value of the property before it is changed, and for this I added the CoerceValueCallback.

public static readonly DependencyProperty MyBackgroundProperty =
        DependencyProperty.Register("MyBackground", typeof(MyCustomizableBackground),
            typeof(MyComponent), new UIPropertyMetadata(default(MyCustomizableBackground), null, new CoerceValueCallback(OnPropertyChanged)));

In OnPropertyChanged I save the value before it's changed. MyCustomizableBackground is the DependencyObject that has also some dependency properties.

The problem is that in this case, where I have a custom object as a property, the OnPropertyChanged method isn't triggered, but when I have a common type, it is triggered.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about dependency-properties