drasto drasto - 1 year ago 106
C# Question

Listen to changes of dependency property

Is there any way to listen to changes of a

? I want to be notified and perform some actions when the value changes but I cannot use binding. It is a
of another class.

Answer Source

If it's a DependencyProperty of a separate class, the easiest way is to bind a value to it, and listen to changes on that value.

If the DP is one you're implementing in your own class, then you can register a PropertyChangedCallback when you create the DependencyProperty. You can use this to listen to changes of the property.

If you're working with a subclass, you can use OverrideMetadata to add your own PropertyChangedCallback to the DP that will get called instead of any original one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download