Add Attach Property to Existing Control
Asked Answered
M

3

0

I want to add a Property such as 'Description' to Button control, that i use it in Tooltip. how can i add a property to a control?

Meingolda answered 8/7, 2012 at 10:13 Comment(0)
F
1

Attached properties are not added to any specific control.

Attached properties are defined in static class, and can be used with any UI control.

Refer to this link to for walkthrough to Add custom attached property.

You can Bind ToolTipService to display tooltip. You need to bind it to Description attached property.

If you want to put property in only one control (so that other controls cannot use it), you need to extend the control, and define Dependency property in it.

Fishnet answered 8/7, 2012 at 10:27 Comment(3)
thnks for the link, but i don't know where should i write those codes and can i replace AquariumObject by Grid?Meingolda
it's on your refered link linkMeingolda
write those code inside static class, and AquariumObject should be replaced by the control class where you want to use attach property. Making it UIElement will allow to use this property to any controlFishnet
M
1

You can use the Tag propery on the button, that is of the type Object and you can store a description text in it if you like.

Millard answered 8/7, 2012 at 14:43 Comment(0)
H
0

Create a new control which inherits from the existing one.

Halitosis answered 8/7, 2012 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.