■ Storyboard 엘리먼트 : TargetProperty 첨부 속성을 사용해 UIElement 엘리먼트 RenderTransform 속성의 애니메이션 설정하기

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

<StackPanel

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

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

    <StackPanel.Resources>

        <Style TargetType="{x:Type Button}">

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

            <Setter Property="Margin"                Value="12"      />

            <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

                                AutoReverse="True"

                                RepeatBehavior="3x"

                                FillBehavior="Stop"

                                Duration="0:0:0.05"

                                From="-5"

                                To="5" />

                        </Storyboard>

                    </BeginStoryboard>

                </EventTrigger>

            </Style.Triggers>

        </Style>

    </StackPanel.Resources>

    <Button>버튼 1</Button>

    <Button>버튼 2</Button>

    <Button>버튼 3</Button>

    <Button>버튼 4</Button>

    <Button>버튼 5</Button>

</StackPanel>

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

Posted by 사용자 icodebroker