Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
A key frame defines a segment of the ThicknessAnimationUsingKeyFrames to which it belongs. Each key frame has a target Value and a KeyTime. The KeyTime specifies the time at which the key frame's Value should be reached. A key frame animates from the target value of the previous key frame to its own target value. It starts when the previous key frame ends and ends when its own key time is reached.
Spline key frames like creates a variable transition between values which is determined by the KeySpline property. Splined interpolation can be used to achieve more realistic "real world" timing effects such as acceleration and deceleration.
During the first half second, uses an instance of the LinearThicknessKeyFrame class to gradually increase the thickness of the border. The example uses LinearThicknessKeyFrame to create a smooth linear increase between values.
At the end of the next half second, uses an instance of the DiscreteThicknessKeyFrame class to suddenly increase the thickness of the border. Discrete key frames like those derived from DiscreteThicknessKeyFrame create sudden jumps between values, that is, the movement of the animation is jerky.
During the final two seconds, uses an instance of the class to decrease the thickness of the border. Spline key frames like those derived from create a variable transition between values according to the values of the KeySpline property. In this key frame, the animation starts off slow and speeds up exponentially toward the end of the time segment.
<!-- This example shows how to use the ThicknessAnimationUsingKeyFrames to create an animation on the BorderThickness property of a Border. --> <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Microsoft.Samples.KeyFrameExamples.ThicknessAnimationUsingKeyFramesExample" Name="myRootElement" WindowTitle="ThicknessAnimationUsingKeyFrames Example"> <StackPanel Orientation="Vertical" HorizontalAlignment="Center"> <Border Background="#99FFFFFF" BorderBrush="#CCCCFF" BorderThickness="1" Margin="0,60,0,20" Padding="20" > <Border.Triggers> <EventTrigger RoutedEvent="Border.Loaded"> <BeginStoryboard> <Storyboard> <!-- Animating the BorderThickness property uses 3 KeyFrames. --> <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Duration="0:0:5" FillBehavior="HoldEnd" RepeatBehavior="Forever"> <ThicknessAnimationUsingKeyFrames.KeyFrames> <!-- Using a LinearThicknessKeyFrame, thickness increases gradually over the first half second of the animation. --> <LinearThicknessKeyFrame KeyTime="0:0:0.5"> <LinearThicknessKeyFrame.Value> <Thickness Left="8" Right="8" Top="6" Bottom="6" /> </LinearThicknessKeyFrame.Value> </LinearThicknessKeyFrame> <!-- Using a DiscreteThicknessKeyFrame, thickness increases suddenly after the first second of the animation. --> <DiscreteThicknessKeyFrame KeyTime="0:0:1"> <DiscreteThicknessKeyFrame.Value> <Thickness Left="28" Right="28" Top="24" Bottom="24" /> </DiscreteThicknessKeyFrame.Value> </DiscreteThicknessKeyFrame> <!-- Using a SplineThicknessKeyFrame, thickness decreases slowly at first and then suddenly contracts. This KeyFrame takes 2 seconds. --> <SplineThicknessKeyFrame KeySpline="0.6,0.0 0.9,0.00" KeyTime="0:0:3"> <SplineThicknessKeyFrame.Value> <Thickness Left="1" Right="1" Top="1" Bottom="8" /> </SplineThicknessKeyFrame.Value> </SplineThicknessKeyFrame> </ThicknessAnimationUsingKeyFrames.KeyFrames> </ThicknessAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Border.Triggers> <TextBlock> This example shows how to use the ThicknessAnimationUsingKeyFrames to create an animation on the BorderThickness property of a Border. </TextBlock> </Border> </StackPanel> </Page>
For the complete sample, see KeyFrame Animation Sample.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.