WPF - 接收属性值更改通知骨架元素的性质 [英] Wpf - Receiving property value change notification for properties of a framework element
本文介绍了WPF - 接收属性值更改通知骨架元素的性质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何挂钩到一个FrameworkElement的属性的属性值更改通知?我们在运行时加载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?
推荐答案
如果你想被当被通知依赖项属性的变化值,你可以这样做(Tag属性的情况下):
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);
这篇关于WPF - 接收属性值更改通知骨架元素的性质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文