Get and set WPF custom attached property from code behind

旧街凉风 提交于 2020-06-12 06:19:42

问题


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.


回答1:


You can set attached properties in code, something like this:

OwningClass.SetMyAttachedProperty(textBox, true);


来源:https://stackoverflow.com/questions/35438746/get-and-set-wpf-custom-attached-property-from-code-behind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!