Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wpf - Receiving property value change notification for properties of a framework element

Tags:

c#

.net

wpf

xaml

How to hook to the property value change notification for properties of a FrameworkElement? We are loading xaml at run time, and for each element in the visual tree, we need to hook up something to receive a property value change notification, when ever some one changes a property value of the element.

What is the best way, if one exists?

like image 507
amazedsaint Avatar asked May 14 '09 13:05

amazedsaint


1 Answers

If you want to be notified when the value of a dependency property changed, you can do that (case of the Tag property) :

DependencyPropertyDescriptor desc = DependencyPropertyDescriptor.FromProperty(FrameworkElement.TagProperty, typeof(FrameworkElement));
desc.AddValueChanged(someObject, someEventHandler);
like image 170
Thomas Levesque Avatar answered Sep 28 '22 05:09

Thomas Levesque