从后面的代码获取并设置WPF自定义附加属性 [英] Get and set WPF custom attached property from code behind
本文介绍了从后面的代码获取并设置WPF自定义附加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我生成框架Rectangle类(已密封)的对象,并以编程方式将其添加到Canvas。我想向该对象添加一些信息。有这种可能性吗?我可以在XAML中获取并设置附加属性,但是这些对我来说没有用。
I generate objects of framework Rectangle class (which is sealed) and programmatically add them to Canvas. I want to add some information to that objects. Is there such a possibility? I can get and set attached properties in XAML but these is not useful for me.
推荐答案
您可以在代码中设置附加属性,
You can set attached properties in code, something like this:
OwningClass.SetMyAttachedProperty(textBox, true);
这篇关于从后面的代码获取并设置WPF自定义附加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文