Key frame animation
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <Canvas> <Rectangle Fill="Red" Width="20" Height="20"> <Rectangle.Triggers> <EventTrigger RoutedEvent="Rectangle.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation From="0" To="800" Duration="0:0:10" Storyboard.TargetProperty="(Canvas.Left)" RepeatBehavior="Forever" AutoReverse="True" /> <DoubleAnimationUsingKeyFrames Duration="0:0:2" Storyboard.TargetProperty="(Canvas.Top)" RepeatBehavior="Forever"> <DoubleAnimationUsingKeyFrames.KeyFrames> <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0" /> <LinearDoubleKeyFrame Value="50" KeyTime="0:0:0.5" /> <LinearDoubleKeyFrame Value="150" KeyTime="0:0:1.5" /> <LinearDoubleKeyFrame Value="50" KeyTime="0:0:2" /> </DoubleAnimationUsingKeyFrames.KeyFrames> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Rectangle.Triggers> </Rectangle> </Canvas> </Page>