问题
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