첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ EventTrigger 엘리먼트를 사용해 버튼 클릭시 버튼을 흔드는 방법을 보여준다.

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 엘리먼트 : 버튼 클릭시 버튼 흔들기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <StackPanel
            HorizontalAlignment="Center"
            VerticalAlignment="Center">
            <StackPanel.Resources>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="HorizontalAlignment"   Value="Center"  />
                    <Setter Property="Margin"                Value="10"      />
                    <Setter Property="Padding"               Value="10"      />
                    <Setter Property="RenderTransformOrigin" Value="0.5 0.5" />
                    <Setter Property="RenderTransform">
                        <Setter.Value>
                            <RotateTransform />
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <EventTrigger RoutedEvent="Button.Click">
                            <BeginStoryboard>
                                <Storyboard TargetProperty="RenderTransform.Angle">
                                    <DoubleAnimation
                                        FillBehavior="Stop"
                                        AutoReverse="True"
                                        RepeatBehavior="3x"
                                        From="-5"
                                        To="5"
                                        Duration="0:0:0.05" />
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Resources>
            <Button>버튼 번호 1</Button>
            <Button>버튼 번호 2</Button>
            <Button>버튼 번호 3</Button>
            <Button>버튼 번호 4</Button>
            <Button>버튼 번호 5</Button>
        </StackPanel>
    </Grid>
</Window>
728x90
그리드형(광고전용)
Posted by icodebroker
,