Example of Multi Trigger in WPF

This blog defines multi trigger in WPF.

<Window x:Class="TypesOfTriggersDemo.MultiTRiggerDEmo"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MultiTRiggerDEmo" Height="300" Width="300" Loaded="Window_Loaded">

    <Window.Resources>

        <Style x:Key="MultTrigg" TargetType="{x:Type TextBox}" >

            <Style.Triggers>

                <MultiTrigger>

                    <MultiTrigger.Conditions>

                        <Condition Property="IsFocused" Value="True"></Condition>

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

                    </MultiTrigger.Conditions>

                    <MultiTrigger.Setters>

                        <Setter Property="Background" Value="yellow" ></Setter>

                    </MultiTrigger.Setters>

                </MultiTrigger>

            </Style.Triggers>

        </Style>

    </Window.Resources>

    <StackPanel>

        <TextBox Style="{StaticResource MultTrigg}"></TextBox>

    </StackPanel>

</Window>

 

 

Ebook Download
View all
Learn
View all