■ DoubleAnimation 엘리먼트 : 진자 운동 애니메이션 만들기

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

 

<Window

    x:Class="TestProject.MainWindow"

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

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

    xmlns:s="clr-namespace:System;assembly=mscorlib"

    Width="600"

    Height="450"

    Title="진자 운동 애니메이션">

    <StackPanel Width="200">

        <Line

            X1="100"

            Y1="0"

            X2="100"

            Y2="200"

            StrokeThickness="3"

            Stroke="Black" />

        <Ellipse

            HorizontalAlignment="Center"

            Width="50"

            Height="50"

            Stroke="Black"

            StrokeThickness="3"

            Fill="Green" />

        <StackPanel.RenderTransform>

            <RotateTransform x:Name="RotateTransformKey"

                CenterX="100"

                CenterY="0" />

        </StackPanel.RenderTransform>

        <StackPanel.Triggers>

            <EventTrigger RoutedEvent="StackPanel.Loaded">

                <BeginStoryboard>

                    <Storyboard

                        TargetName="RotateTransformKey"

                        TargetProperty="Angle">

                        <DoubleAnimation

                            RepeatBehavior="Forever"

                            AutoReverse="True"

                            AccelerationRatio="0.5"

                            DecelerationRatio="0.5"

                            Duration="0:0:1"

                            From="-30"

                            To="30" />

                    </Storyboard>

                </BeginStoryboard>

            </EventTrigger>

        </StackPanel.Triggers>

    </StackPanel>

</Window>

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

Posted by 사용자 icodebroker

댓글을 달아 주세요