Add an attachment property to an existing control

I want to add a property, such as a Description, to the Button control that I use in Tooltip. How can I add a property to a control?

0
source share
3 answers

Attached properties are not added to any particular control.

Attached properties are defined in a static class and can be used with any user interface control.

Refer to this link for a walk on adding a custom attached property.

You can bind ToolTipService to display a tooltip. You must bind it to the Description of the attached property.

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

+1
source

You can use the Tag property on a button that is of type Object, and you can save description text in it if you want.

+1
source

Create a new control that inherits from the existing one.

0
source

Source: https://habr.com/ru/post/972209/


All Articles