How to change the visual state of a ControlTemplate without replacing it?

I want to determine ToggleButtonwhich one is displayed with a red foreground (for example) if it is installed, and not by default by clicking a button.

I see that visual states are supported as named elements inside ToggleButton ControlTemplate.

What is the easiest way to replace / remove / set up a visual state WITHOUT overriding the entire template?

+3
source share
2 answers

I understand that this is very late, but I just ran into the same problem and figured out the solution myself, so I hope this will be useful to someone.

, ( /), VisualTreeHelper.GetChild (myToggleButton, 0) - , // Children.

, , , , , - .

: ControlTemplate Silverlight 3?

+1

ControlTemplate BasedOn , , ?

-1

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


All Articles