"새 프로젝트"만들기로 "RiaTriggers"프로젝트를 만든다.
그리고 아래 그림과 같이 참조추가 한 후, [MainPage.xaml]소스코드에서 "xmlns"부분을 2줄 추가하고 아래와 같이 코드를 작성한다 .













[MainPage.xaml]


<UserControl x:Class="RiaTriggers.MainPage"

    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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

    xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"

   

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">

        <Button x:Name="btn" Content="버튼">

            <i:Interaction.Triggers>

                <i:EventTrigger EventName="Click">

                    <ic:ChangePropertyAction TargetName="btn" PropertyName="Background">

                        <ic:ChangePropertyAction.Value>

                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

                                <GradientStop Color="Black" Offset="0"/>

                                <GradientStop Color="Red" Offset="1"/>

                            </LinearGradientBrush>

                        </ic:ChangePropertyAction.Value>

                    </ic:ChangePropertyAction>

                </i:EventTrigger>

            </i:Interaction.Triggers>

        </Button>

    </Grid>

</UserControl>

 

 








Posted by holland14
: