During the first three seconds, uses an instance of the LinearDoubleKeyFrame class to move the rectangle along a path at a steady rate from its starting position to the 500 position. Linear key frames like LinearDoubleKeyFrame create a smooth linear transition between values.

At the end of the fourth second, uses an instance of the DiscreteDoubleKeyFrame class to suddenly move the rectangle to the next position. Discrete key frames like DiscreteDoubleKeyFrame create sudden jumps between values. In this example, the rectangle is at the starting position and then suddenly appears at the 500 position.

In the final two seconds, uses an instance of the SplineDoubleKeyFrame class to move the rectangle back to its starting position. Spline key frames like SplineDoubleKeyFrame create a variable transition between values according to the value of the KeySpline property. In this example, the rectangle begins by moving slowly and then speeds up exponentially toward the end of the time segment.

<!-- This example shows how to use the DoubleAnimationUsingKeyFrames to
animate the position of an object.
Key frame animations enable you to create complex animations
by specifying multiple destination values
and controlling the animation's interpolation method.
--><Pagexmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="DoubleAnimationUsingKeyFrames Example"Background="White"Margin="20"><CanvasWidth="610"Height="300"><!-- The position of this rectangle is animated using
a key frame animation. --><RectangleCanvas.Top="100"Canvas.Left="10"Height="100"Width="100"Stroke="Black"StrokeThickness="5"><Rectangle.RenderTransform><TranslateTransformx:Name="AnimatedTranslateTransform"/></Rectangle.RenderTransform><Rectangle.Triggers><EventTriggerRoutedEvent="Rectangle.Loaded"><BeginStoryboard><Storyboard><!-- Animate the TranslateTransform.X property using 3 KeyFrames
which animates the rectangle along a straight line.
This animation repeats indefinitely. --><DoubleAnimationUsingKeyFramesStoryboard.TargetName="AnimatedTranslateTransform"Storyboard.TargetProperty="X"Duration="0:0:6"RepeatBehavior="Forever"><!-- Using a LinearDoubleKeyFrame, the rectangle moves
steadily from its starting position to 500 over
the first 3 seconds. --><LinearDoubleKeyFrameValue="500"KeyTime="0:0:3"/><!-- Using a DiscreteDoubleKeyFrame, the rectangle suddenly
appears at 400 after the fourth second of the animation. --><DiscreteDoubleKeyFrameValue="400"KeyTime="0:0:4"/><!-- Using a SplineDoubleKeyFrame, the rectangle moves
back to its starting point. The
animation starts out slowly at first and then speeds up.
This KeyFrame ends after the 6th
second. --><SplineDoubleKeyFrameKeySpline="0.6,0.0 0.9,0.00"Value="0"KeyTime="0:0:6"/></DoubleAnimationUsingKeyFrames></Storyboard></BeginStoryboard></EventTrigger></Rectangle.Triggers></Rectangle></Canvas></Page>