Wednesday, March 06, 2013

What is the Triggers in WPF?

Posted by Rahul Kharde at 7:57 AM
Triggers are implemented as part of styles, and indicate a trigger condition and a new set of setters to apply when the trigger condition is met. Mouseover effects are a very common application of triggers. Triggers can fully be expressed using XAML, eliminating the need to write code for many simple effects.

There are three types of triggers in WPF:

1. Property Triggers - run when the value of a dependency property changes
2. Data Triggers - run when the value of any .NET property changes, using data binding
3. Event Triggers - run when a routed event occurs

Triggers are implement as part of a style using the <Style.Triggers> property element, and a series of <Trigger>,<DataTrigger>, or <EventTrigger> elements.

Property Triggers
Property triggers are used to monitor a DependencyProperty's value. The following example applies a glow effect to a button when the mouse pointer is over the button (IsMouseOver=true). The WPF framework automatically handles resetting the style back when the mouse pointer is moved off the button.

If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!

Kindly Bookmark and Share it:



Have any question? Feel Free To Post Below:


Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top