Understanding Triggers
Until now you saw how styles can be applied to controls without condition. This is useful, but it is more useful for deciding when to apply a style. The easiest example is to consider a button; you apply a background color that you might want to change when the mouse pointer passes over the button, and this behavior should be replicated for each button in the UI via styles. To conditionally apply styles, you use triggers. A trigger essentially represents a condition that enables applying a particular style when the condition is evaluated as True. Triggers are defined within a Style.Triggers collection, and each of them requires specifying the property affected by the condition and a Boolean value (True or False) that determines ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access