■ DoubleAnimationUsingPath 엘리먼트 사용하기

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

 

<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="800"

    Title="DoubleAnimationUsingPath 엘리먼트 사용하기">

    <Canvas>

        <Canvas.Resources>

            <PathGeometry x:Key="PathGeometryKey"

                Figures="M 96 192 C 288 0, 384 384, 576 192 S 662 192 576 576 S 384 576 96 192" />

        </Canvas.Resources>

        <Path

            Stroke="Black"

            Data="{StaticResource PathGeometryKey}" />

        <Button Name="button"

            Width="60"

            Height="25"

            Content="버튼">

            <Button.RenderTransform>

                <RotateTransform x:Name="rotateTransform" />

            </Button.RenderTransform>

        </Button>

        <Canvas.Triggers>

            <EventTrigger RoutedEvent="Canvas.Loaded">

                <BeginStoryboard>

                    <Storyboard

                        RepeatBehavior="Forever">

                        <DoubleAnimationUsingPath

                            Storyboard.TargetName="button"

                            Storyboard.TargetProperty="(Canvas.Left)"

                            Duration="0:0:10"

                            Source="X"

                            PathGeometry="{StaticResource PathGeometryKey}" />

                        <DoubleAnimationUsingPath

                            Storyboard.TargetName="button"

                            Storyboard.TargetProperty="(Canvas.Top)"

                            Duration="0:0:10"

                            Source="Y"

                            PathGeometry="{StaticResource PathGeometryKey}" />

                        <DoubleAnimationUsingPath

                            Storyboard.TargetName="rotateTransform"

                            Storyboard.TargetProperty="Angle"

                            Source="Angle"

                            Duration="0:0:10"

                            PathGeometry="{StaticResource PathGeometryKey}" />

                    </Storyboard>

                </BeginStoryboard>

            </EventTrigger>

        </Canvas.Triggers>

    </Canvas>

</Window>

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

Posted by 사용자 icodebroker