[WPF] How to be notified when an internal DependencyProperty is modified ?

When you create your own Dependency Properties, you can define some callbacks that will be called when the value of the property is modified. But, how to do the same with an internal Dependency Property of WPF ?

Here is a sample:

public MyControl()

{

    DependencyPropertyDescriptor.FromProperty(WidthProperty, typeof(MyControl)).AddValueChanged(this,

        delegate

            {

                MessageBox.Show("Value has been modified!");

            });

}

As you can see, you need to call the FromProperty method of the DependencyPropertyDescriptor class, passing it the Dependency Property that you want to track, the type of your control and then, calling the AddValueChanged method with a delegate to the code that need to be called when the property is modified.

As you can see, it’s simple but very useful and it appears to be the only way to know when a row is selected on the XCeed datadrig…

 

Hope this helps !

 

Thanks.

No Comments