MatrixAnimationUsingKeyFrames.KeyFrames Property
Gets or sets the collection of MatrixKeyFrame objects that define the animation.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
'Declaration Public Property KeyFrames As MatrixKeyFrameCollection 'Usage Dim instance As MatrixAnimationUsingKeyFrames Dim value As MatrixKeyFrameCollection value = instance.KeyFrames instance.KeyFrames = value
<object> <MatrixKeyFrameCollection .../> </object>
Property Value
Type: System.Windows.Media.Animation.MatrixKeyFrameCollectionThe collection of MatrixKeyFrame objects that define the animation. The default value is Empty.
This example shows how to animate the Matrix property of a MatrixTransform by using key frames.
The following example uses the MatrixAnimationUsingKeyFrames class to animate the Matrix property of a MatrixTransform. The example uses the MatrixTransform object to transform the appearance and position of a Button.
This animation uses the DiscreteMatrixKeyFrame class to create two key frames and does the following with them:
Animates the first Matrix during the first 0.2 seconds. The example changes the M11 and M12 properties of the Matrix. This change causes the button to stretch and become skewed. The example also changes the OffsetX and OffsetY properties so that the button changes position.
Animates the second Matrix at 1.0 seconds. The button moves to another position while the button is no longer skewed or stretched.
Repeats the animation indefinitely.
Note: |
|---|
Key frames that derive from the DiscreteMatrixKeyFrame object create sudden jumps between values, that is, the movement of the animation is jerky. |
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MatrixAnimationUsingPath Example"> <StackPanel Margin="20"> <Canvas HorizontalAlignment="Left" Width="340" Height="240" > <!-- The Button that is animated. --> <Button Margin="-30,0,0,0" MinWidth="100"> Click <Button.RenderTransform> <MatrixTransform x:Name="myMatrixTransform"> <MatrixTransform.Matrix > <Matrix OffsetX="10" OffsetY="100"/> </MatrixTransform.Matrix> </MatrixTransform> </Button.RenderTransform> <Button.Triggers> <EventTrigger RoutedEvent="Button.Loaded"> <BeginStoryboard> <Storyboard> <!-- Animates the button's MatrixTransform using MatrixAnimationUsingKeyFrames. Animates to first Matrix in the first 0.2 seconds, to second Matrix in the next second, and then starts over. Notice that the first KeyFrame stretches the button and skews it using the M11 and M12 Matrix properties respectively. Also, animations are using Discrete interpolation, so the MatrixTransform appears to "jump" from one value to the next. --> <MatrixAnimationUsingKeyFrames Storyboard.TargetName="myMatrixTransform" Storyboard.TargetProperty="Matrix" Duration="0:0:3" RepeatBehavior="Forever"> <DiscreteMatrixKeyFrame KeyTime="0:0:0.2"> <DiscreteMatrixKeyFrame.Value> <Matrix OffsetX="100" OffsetY="200" M11="3" M12="1" /> </DiscreteMatrixKeyFrame.Value> </DiscreteMatrixKeyFrame> <DiscreteMatrixKeyFrame KeyTime="0:0:1"> <DiscreteMatrixKeyFrame.Value> <Matrix OffsetX="300" OffsetY="100" M11="1" M12="0" /> </DiscreteMatrixKeyFrame.Value> </DiscreteMatrixKeyFrame> </MatrixAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> </Button> </Canvas> </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.
Note: