I have a Static Dependency Property and I need to know when its value changes so I can call a callback and update a value else where. Right now I can't do it because the callback isn't static and the Dependency change event is.
I have it currently working when the LostFocus event fires, but I'd prefer to have it wired up to whenever a change occurs.
The dependency property change notification passes in the object. You can use that to map to a non-static variable:
static void OnThePropChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
YourClass instance = (YourClass)obj;
instance.ThePropChanged(args); // Call non-static
// Alternatively, you can just call the callback directly:
// instance.CallbackMethod(...)
}
// This is a non-static version of the dep. property changed event
void ThePropChanged(DependencyPropertyChangedEventArgs args)
{
// Raise your callback here...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With