Managing the states of a control
In the previous section, we saw a glimpse of a new important concept in XAML – visual states. A visual state is a way to represent the look and feel of a control in a specific situation. For example, a Button
control can be pressed, disabled, or highlighted. In all these states, Button
has a different aspect than the default one, as you can see in the following screenshot:
The power of visual states is that they simplify the management of the various states that a control can assume, since you don't have to specify the whole template each time. A visual state just specifies the differences compared to the default template of the control.
As an example, let's take a look at the VisualState
definition called Pressed
of a Button
control:
<VisualState x:Name="Pressed"> <Storyboard> ...