附加属性添加代码 [英] Attached Properties Add With Code
本文介绍了附加属性添加代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用C#代码示例创建名称时,我希望将属性附加到元素上,将名称设置为TranslateTransform Class.
可能吗?如果是这样,怎么办?(请写示例)
谢谢.
I want attached properties to element''s when i create them with C# code example set Name to TranslateTransform Class .
Is it Possible? if so, how?(please write example)
thanks.
推荐答案
它们只是我能想到的一种方法:您必须作弊".
浏览正在创建的Element上的属性(例如UIElement),找到不使用的字符串属性,并且控件也没有设置(例如某些文化语言字符串).然后,您可以使用它以(例如字符串)格式保存数据,并在需要时将其拉出.
如果您可以显示所使用的元素类型,则可以发布一些代码.
希望这会有所帮助.
ge-force.
Their is only one way I can think of: you have to "cheat".
Looks through the properties on the Element you are creating (e.g. UIElement), and find a string property that you won''t use, and the control doesn''t set either (e.g. some cultural language string). Then, you can use this to hold your data in a (e.g. string) format, and pull it out whenever you want.
If you could show which type of Element you are using, I might be able to post some code.
Hope this helps.
ge-force.
使用构造函数在创建对象时初始化其值.
http://msdn.microsoft.com/en-us/library/ms173115.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms173115%28v = vs.80%29.aspx [ ^ ]
我不太确定构造函数是否可以帮助您解决问题,但从我的角度来看,应该这样做:)
问候,
爱德华
Use Constructors to initialize its values upon object creation.
http://msdn.microsoft.com/en-us/library/ms173115.aspx[^]
http://msdn.microsoft.com/en-us/library/ms173115%28v=vs.80%29.aspx[^]
I am not quite sure if Constructors will help you from your problem but from my point of view, that should do it :)
Regards,
Eduard
这篇关于附加属性添加代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文