Dawid Jablonski
Dawid Jablonski

Reputation: 583

Get and set WPF custom attached property from code behind

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.

Upvotes: 10

Views: 5640

Answers (1)

James Willock
James Willock

Reputation: 2037

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

OwningClass.SetMyAttachedProperty(textBox, true);

Upvotes: 22

Related Questions