첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형

■ EventTrigger 엘리먼트 : RoutedEvent 속성을 사용해 복권 긁는 효과 사용하기

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


TestProject.zip



MainWindow.xaml

 

 

<Window x:Class="TestProject.MainWindow"

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

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

    Width="800"

    Height="600"

    Title="EventTrigger 엘리먼트 : RoutedEvent 속성을 사용해 복권 긁는 효과 사용하기"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Grid

        Width="500"

        Height="500"

        Background="RoyalBlue">

        <Image

            Width="500"

            Height="500"

            Stretch="Fill"

            Source="sample.jpg" />

        <WrapPanel SnapsToDevicePixels="True">

            <WrapPanel.Resources>

                <Style TargetType="Rectangle">

                    <Setter Property="Width" Value="50"    />

                    <Setter Property="Height" Value="50"    />

                    <Setter Property="Fill"   Value="Black" />

                    <Style.Triggers>

                        <EventTrigger RoutedEvent="Rectangle.MouseEnter">

                            <EventTrigger.Actions>

                                <BeginStoryboard>

                                    <Storyboard Storyboard.TargetProperty="(Rectangle.Opacity)">

                                        <DoubleAnimation To="0" Duration="0:0:0.5"/>

                                        <ColorAnimation

                                            Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)"

                                            To="White"

                                            Duration="0:0:0.5" />

                                    </Storyboard>

                                </BeginStoryboard>

                            </EventTrigger.Actions>

                        </EventTrigger>

                    </Style.Triggers>

                </Style>

            </WrapPanel.Resources>

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

            <Rectangle /><Rectangle /><Rectangle /><Rectangle /><Rectangle />

        </WrapPanel>

    </Grid>

</Window>

 

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

728x90
반응형
Posted by 사용자 icodebroker

댓글을 달아 주세요