I need to run some custom code in a User Control when a certain custom dependency property (defined in a parent User Control) has changed. What is the best way to do this in WPF?
I have spent a good bit of time playing with triggers in XAML which use data binding to access my CDP, and found a solution which requires setting an intermediate CDP (in the child user control), and then running my custom code in that second CDP's changed event. However this is pretty messy and doesn't seem to be the proper use of WPF. Also the code I am running isn't directly related to the UI, so XAML doesn't seem to be appropriate here.
Assuming the child user control's DataContext is properly set such that I can access the CDP, how can I write code to simply execute a callback function when the CDP is changed?
I already have an "OnXXXChanged" callback in the high-level parent control, but that control doesn't know anything about the child control so it cannot easily cause code to execute in the child control's object.