Triggers

Triggers enable you to set or modify attributes of an element based on a specific action. Triggers can either act on single instances of an element or they can affect an entire class of elements.

A simple example of a trigger and its corresponding action is that of a button changing its background color based on a mouse hover or mouse click action.

The Style, ControlTemplate, and DataTemplate elements have a Triggers property that contains a set of triggers.

Triggers in WPF are of various types: property triggers, event triggers, data triggers, multi triggers, and multi data triggers.

Property Triggers

Supported By

WPF

Yes

Silverlight

Yes

Defining a property trigger is simple. You define a Trigger element, specify the property change that initiates ...

Get XAML Developer Reference 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.