■ Trigger 엘리먼트 사용하기

----------------------------------------------------------------------------------------------------

<StackPanel

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

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

    <StackPanel.Resources>

        <Style x:Key="ButtonStyleKey">

            <Setter Property="Control.HorizontalAlignment" Value="Center" />

            <Setter Property="Control.Margin"              Value="24"     />

            <Setter Property="Control.FontSize"            Value="24"     />

            <Style.Triggers>

                <Trigger Property="Control.IsMouseOver" Value="true">

                    <Setter Property="Control.FontStyle" Value="Italic" />

                    <Setter Property="Control.Foreground" Value="Blue"   />

                </Trigger>

                <Trigger Property="Button.IsPressed" Value="true">

                    <Setter Property="Control.Foreground" Value="Red" />

                </Trigger>

            </Style.Triggers>

        </Style>

    </StackPanel.Resources>

    <Button Style="{StaticResource ButtonStyleKey}">버튼 1</Button>

    <Button Style="{StaticResource ButtonStyleKey}">버튼 2</Button>

    <Button Style="{StaticResource ButtonStyleKey}">버튼 3</Button>

</StackPanel>

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요