Thomas Lebrun

All you need about WPF, Silverlight & LINQ !

February 2009 - Posts

[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.

Posted: Feb 27 2009, 10:12 AM by Thomas Lebrun | with no comments
Filed under: ,
Welcome to my English blog !

Hello everybody,

This is my first post on this blog so I’ll try to present myself to let you know who I’m !

My name is Thomas LEBRUN and I’m currently a consultant and trainer (MCT) at Winwise in Paris (France). I started to use .NET in 2002, in particular C# language. For my contributions to the french community, Microsoft has honored me with the title of Client Application Development MVP since 2007.

My main role is architect on Smart Client technologies: WPF, Silverlight, etc.. I speak at some conferences for Winwise or Microsoft (TechDays), mainly about Windows Presentation Foundation, Silverlight and VSTO (Office Development).

I’ve a french blog that’s located here: http://blogs.codes-sources.com/tom (fr). This blog mainly devotes itself to Windows Presentation Foundation & Silverlight. Also, I write articles for http://www.techheadbrothers.com (fr), http://ww.developpez.com (fr) and on a French magazine “Programmez”.

For my first posts on this blog, I will just translate the posts that are currently on my french blog and I hope they will be useful !

Thanks !

 

PS: As you will probably doubt, English is not my primary language so, in advance, forgive me for any mistakes I can do [:)]

More Posts