Animation target Canvas Left, Top

image_pdfimage_print


   
      

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

    <Ellipse Width="48" Height="48" Fill="Red" Canvas.Left="0" Canvas.Top="0">
        <Ellipse.Triggers>
            <EventTrigger RoutedEvent="Ellipse.MouseDown">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation 
                            Storyboard.TargetProperty="(Canvas.Left)"
                            From="0" To="300" Duration="0:0:0.25"
                            AutoReverse="True" 
                            RepeatBehavior="20x" />
                        <DoubleAnimation 
                            Storyboard.TargetProperty="(Canvas.Top)"
                            From="0" To="480" Duration="0:0:5"
                            AutoReverse="True" />
                        <ParallelTimeline BeginTime="0:0:10" FillBehavior="Stop">
                            <DoubleAnimation Storyboard.TargetProperty="Width" From="48" To="480" Duration="0:0:1" />
                            <DoubleAnimation Storyboard.TargetProperty="Height" From="48" To="480" Duration="0:0:1" />
                        </ParallelTimeline>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Ellipse.Triggers>
    </Ellipse>
</Canvas>