Blog

Multi Condition Triggers in WPF

Posted by Mahak Gupta Blogs | WPF Feb 29, 2012
Multi-Condition triggers are useful when we need to evaluate multiple condition evaluation at a particular time.

Multi-Condition triggers are useful when we need to evaluate multiple condition evaluation at a particular time. This element provides a check constraint for all of the conditional statements to be evaluated to True in order for it to take effect.

 <Window.Resources>
            <Style TargetType="{x:Type Button}">
                <Style.Triggers>
                    <MultiTrigger>

                        <MultiTrigger.Conditions>
                            <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="Content" Value="Mahak" />
                        </MultiTrigger.Conditions>
                        <Setter Property="Background" Value="Pink" />
                    </MultiTrigger>
                </Style.Triggers>
            </Style>
        </Window.Resources>
    <Grid>
        <Button Height="26" Name="Button1" >Mahak
        </Button>
    </Grid> 

In this example we check two conditions: 

Condition Property="IsMouseOver" Value="True" />
  <Condition Property="Content" Value="Mahak" /> 

First we check the InMouseOver property and after that we check the content of the control Button if it is “Mahak” the background of the Button must be pink. 


COMMENT USING
PREMIUM SPONSORS
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.