021. Multi Trigger
반응형

이번엔 Multi Trigger이다.

 

말그대로 여러개의 Trigger라고 생각하면될듯싶다

 

즉 

 

1
2
3
4
5
if( 조건1 && 조건2)
{
    // 수행
}
 
cs

 

이런거로 보면 될듯 싶다.

 

코드 ㄱㄱ

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<Window x:Class="TestProject.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TestProject"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
            <CheckBox Name="cbSampleYes" Content="Yes" />
            <CheckBox Name="cbSampleSure" Content="I'm sure" />
            <TextBlock HorizontalAlignment="Center" Margin="0,20,0,0" FontSize="28">
                <TextBlock.Style>
                    <Style TargetType="TextBlock">
                        <Setter Property="Text" Value="Unverified" />
                        <Setter Property="Foreground" Value="Red" />
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding ElementName=cbSampleYes, Path=IsChecked}" Value="True" />
                                    <Condition Binding="{Binding ElementName=cbSampleSure, Path=IsChecked}" Value="True" />
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Text" Value="Verified" />
                                <Setter Property="Foreground" Value="Green" />
                            </MultiDataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </StackPanel>
    </Grid>
</Window>
 
cs

 

CheckBox를 2개 두고 2개가 모두다 check되면 글씨의 색상과 내용을 변경하는 코드..

 

어렵지 않죠..?

 

수행화면

 

 

 

굳.!

 

코드는

TestProject.zip
0.05MB

 

반응형