Gets or sets the key frame's target value.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
This example shows how to animate the value of a property that takes a Double by using key frames.
The following example moves a rectangle across a screen. The example uses the DoubleAnimationUsingKeyFrames class to animate the X property of a TranslateTransform applied to a Rectangle. This animation, which repeats indefinitely, uses three key frames in the following manner:
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. --> <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="DoubleAnimationUsingKeyFrames Example" Background="White" Margin="20"> <Canvas Width="610" Height="300"> <!-- The position of this rectangle is animated using a key frame animation. --> <Rectangle Canvas.Top="100" Canvas.Left="10" Height="100" Width="100" Stroke="Black" StrokeThickness="5"> <Rectangle.RenderTransform> <TranslateTransform x:Name="AnimatedTranslateTransform" /> </Rectangle.RenderTransform> <Rectangle.Triggers> <EventTrigger RoutedEvent="Rectangle.Loaded"> <BeginStoryboard> <Storyboard> <!-- Animate the TranslateTransform.X property using 3 KeyFrames which animates the rectangle along a straight line. This animation repeats indefinitely. --> <DoubleAnimationUsingKeyFrames Storyboard.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. --> <LinearDoubleKeyFrame Value="500" KeyTime="0:0:3" /> <!-- Using a DiscreteDoubleKeyFrame, the rectangle suddenly appears at 400 after the fourth second of the animation. --> <DiscreteDoubleKeyFrame Value="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. --> <SplineDoubleKeyFrame KeySpline="0.6,0.0 0.9,0.00" Value="0" KeyTime="0:0:6" /> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Rectangle.Triggers> </Rectangle> </Canvas> </Page>
For the complete sample, see KeyFrame Animation Sample.
For consistency with other animation examples, the code versions of this example use a Storyboard object to apply the DoubleAnimationUsingKeyFrames. Alternatively, when applying a single animation in code, it is simpler to use the BeginAnimation method instead of using a Storyboard. For an example, see How to: Animate a Property Without Using a Storyboard.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.