Diese Dokumentation wurde archiviert und wird nicht länger gepflegt.

MatrixAnimationUsingKeyFrames-Klasse

Animates the value of a Matrix property along a set of KeyFrames.

Namespace: System.Windows.Media.Animation
Assembly: PresentationCore (in presentationcore.dll)
XML-Namespaces:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[ContentPropertyAttribute("KeyFrames")] 
public class MatrixAnimationUsingKeyFrames : MatrixAnimationBase, IKeyFrameAnimation, IAddChild
/** @attribute ContentPropertyAttribute("KeyFrames") */ 
public class MatrixAnimationUsingKeyFrames extends MatrixAnimationBase implements IKeyFrameAnimation, IAddChild
ContentPropertyAttribute("KeyFrames") 
public class MatrixAnimationUsingKeyFrames extends MatrixAnimationBase implements IKeyFrameAnimation, IAddChild
<MatrixAnimationUsingKeyFrames>
  KeyFrames
</MatrixAnimationUsingKeyFrames>

A key frame animation's target values are defined by its KeyFrames property, which contains a collection of MatrixKeyFrame objects. Each MatrixKeyFrame defines a segment of the animation with its own target Value and KeyTime. When the animation runs, it progresses from one key value to the next at the specified key times.

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:

  1. 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.

  2. Animates the second Matrix at 1.0 seconds. The button moves to another position while the button is no longer skewed or stretched.

  3. Repeats the animation indefinitely.

HinweisHinweis:

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.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Freezable
         System.Windows.Media.Animation.Animatable
           System.Windows.Media.Animation.Timeline
             System.Windows.Media.Animation.AnimationTimeline
               System.Windows.Media.Animation.MatrixAnimationBase
                System.Windows.Media.Animation.MatrixAnimationUsingKeyFrames

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.

.NET Framework

Unterstützt in: 3.0
Anzeigen: