C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » WPF »

WPF Multitrigger


Posted Date: 05 Sep 2009    Resource Type: Articles    Category: WPF
Author: ABitSmartMember Level: Diamond    
Rating: 1 out of 5Points: 12



This article discusses and demonstrates the implementation of a trigger in WPF which has multiple conditions.

Triggers in WPF are very important and handy features. Triggers and styles add to WPF's bag a rich set of functionality. Triggers are like event handlers which we define in XAML's DateTemplates and styles.Triggers allow us to define several Setter elements in a style. The trigger includes a condition, and when that condition is true, the Setters defined in the trigger will be applied. When the condition is false, the Setters are ignored.

Here is a sample trigger,

<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</Trigger>
</Style.Triggers>


The above example demonstrates a Style trigger which fires when the IsEnabled property is false. The resulting controls Visibility property will be set to Collapsed.

Moving ahead, what if our condition is based on multiple criteria? Here comes the use of MultiTriggers.

Here is a sample Multi-Trigger,

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Content" Value="a" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed" />
</MultiTrigge>


The above trigger will fire when Content has a value of "a" and mouse is over the control.

Have fun.

For more details, visit http://abitsmart.com/?p=166



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
WPF multitrigger: Multitrigger in WPF  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Windows 7 Multitouch Application Development (Part - I)
Previous Resource: Windows 7 Multitouch Application Development (Part - II)
Return to Discussion Resource Index
Post New Resource
Category: WPF


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use