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(OnPropertyChanging)));
In OnPropertyChanging 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 OnPropertyChanging method isn't triggered, but when I have a common type, it is triggered.
Later edit: I realised that a part of my question was quite ambiguous and I asked a separate question here. For the first part of the problem, Julien pointed me in a better direction.