Wednesday, February 1, 2017

Triggers in WPF

What is Trigger ?

Trigger defines a list of setters that are executed on specific condition. Triggers are used in style tag or Template Control.
Why do use Trigger?

By using Triggers we can change the appearance of Framework Elements.

How many types of triggers are in WPF?

There are five types of triggers supported by WPF; they are:

Property Trigger

Data Trigger



Event Trigger

Property Triggers executes, when a property gets a specified value.
MultiTrigger executes, when multi property changed.
MultiDataTrrigger MultiTrigger and MultiDataTrigger are the same, except they allow you to specify multiple conditions (properties or bindings respectively) and take effect only when all conditions are satisfied.
Event Triggers executes, when a specified event is fired.
Data Triggers executes, when a binding expression reaches a specified value.

Property trigger used with dependency properties, data trigger used with normal properties and event trigger used for animation.

Property Trigger Example -

It says that if mouse over on specific control than control color will be red.

Event Trigger Example

MultiTrigger Example

MultiDataTrigger Example

Data Trigger Example

No comments: