Visual States

You might have noticed that something is still missing from all versions of the custom Button template used in the preceding section. None of them have any visual reaction to being pressed, hovered over, or disabled. This might not be that big of a deal, depending on their usage, but imagine applying the same template to CheckBox or ToggleButton. (This can be done by changing the TargetType to ButtonBase or a more specific type.) Because the template doesn’t show different visuals for the Checked versus Unchecked versus Indeterminate states, it’s a pretty lousy template for these controls!

Therefore, a good control template must consider all possible visual states relevant for the target control and handle them appropriately. To ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.