■ ControllableStoryboardAction 하위 엘리먼트 사용하기

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

<StackPanel

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

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

    <Canvas

        Width="350"

        Height="200">

        <Rectangle

            Canvas.Left="150"

            Canvas.Top="50"

            Fill="Aqua"

            Width="50"

            Height="150"

            Stroke="Black"

            StrokeThickness="4">

            <Rectangle.RenderTransform>

                <TransformGroup>

                    <RotateTransform x:Name="rotateTransform1"

                        Angle="-90"

                        CenterX="0"

                        CenterY="150" />

                    <RotateTransform x:Name="rotateTransform2"

                        CenterX="50"

                        CenterY="150" />

                </TransformGroup>

            </Rectangle.RenderTransform>

        </Rectangle>

    </Canvas>

    <StackPanel

        Orientation="Horizontal"

        HorizontalAlignment="Center">

        <Button Name="beginButton" Margin="12" Content="시작"     />

        <Button Name="pauseButton" Margin="12" Content="정지"     />

        <Button Name="resumeButton" Margin="12" Content="재개"     />

        <Button Name="stopButton"   Margin="12" Content="중단"     />

        <Button Name="skipButton"   Margin="12" Content="끝으로"   />

        <Button Name="centerButton" Margin="12" Content="중간으로" />

    </StackPanel>

    <StackPanel.Triggers>

        <EventTrigger SourceName="beginButton" RoutedEvent="Button.Click">

            <BeginStoryboard Name="beginStoryboard">

                <Storyboard >

                    <DoubleAnimation

                        Storyboard.TargetName="rotateTransform1"

                        Storyboard.TargetProperty="Angle"

                        From="-90"

                        To="0"

                        Duration="0:0:5" />

                    <DoubleAnimation

                        Storyboard.TargetName="rotateTransform2"

                        Storyboard.TargetProperty="Angle"

                        Duration="0:0:5"

                        BeginTime="0:0:5"

                        From="0"

                        To="90" />

                </Storyboard>

            </BeginStoryboard>

        </EventTrigger>

        <EventTrigger

            SourceName="pauseButton"

            RoutedEvent="Button.Click">

            <PauseStoryboard BeginStoryboardName="beginStoryboard" />

        </EventTrigger>

        <EventTrigger

            SourceName="resumeButton"

            RoutedEvent="Button.Click">

            <ResumeStoryboard BeginStoryboardName="beginStoryboard" />

        </EventTrigger>

        <EventTrigger

            SourceName="stopButton"

            RoutedEvent="Button.Click">

            <StopStoryboard BeginStoryboardName="beginStoryboard" />

        </EventTrigger>

        <EventTrigger

            SourceName="skipButton"

            RoutedEvent="Button.Click">

            <SkipStoryboardToFill BeginStoryboardName="beginStoryboard" />

        </EventTrigger>

        <EventTrigger

            SourceName="centerButton"

            RoutedEvent="Button.Click">

            <SeekStoryboard BeginStoryboardName="beginStoryboard" Offset="0:0:5" />

        </EventTrigger>

    </StackPanel.Triggers>

</StackPanel>

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

Posted by 사용자 icodebroker