KeyFrameAnimation.Direction Eigenschaft

Definition

Die Richtung, in der die Animation wiedergegeben wird.

Mit der Direction-Eigenschaft können Sie Ihre Animation von Anfang zu Ende oder von Anfang zu Anfang oder zwischen Start und Ende oder Ende oder Ende zu Starten steuern, wenn die Animation einen IterationCount größer als eins aufweist. Dies bietet eine einfache Möglichkeit zum Anpassen von Animationsdefinitionen.

public:
 property AnimationDirection Direction { AnimationDirection get(); void set(AnimationDirection value); };
AnimationDirection Direction();

void Direction(AnimationDirection value);
public AnimationDirection Direction { get; set; }
var animationDirection = keyFrameAnimation.direction;
keyFrameAnimation.direction = animationDirection;
Public Property Direction As AnimationDirection

Eigenschaftswert

Die Richtung, in der die Animation wiedergegeben wird.

Windows-Anforderungen

Gerätefamilie
Windows 10 Anniversary Edition (eingeführt in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v3.0)

Beispiele

AnimationDirection ist Normal

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is normal i.e. forward. 
    animation.Direction = AnimationDirection.Normal; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

AnimationDirection ist umgekehrt

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is Reverse i.e. end to start. 
    animation.Direction = AnimationDirection.Reverse; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

AnimationDirection ist Alternativ

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is alternate i.e. start to end and then end to start and so on. 
    animation.Direction = AnimationDirection.Alternate; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

AnimationDirection ist AlternateReverse.

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is alternate-reverse i.e. end to start and then start to end and so on. 
    animation.Direction = AnimationDirection.AlternateReverse; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

Hinweise

Bei einer Offsetanimation mit einer Iterationsanzahl von 3 und zwei Keyframes (0 und 1) mit dem Wert Vector3(5,5,5) für Keyframe 0 und dem Wert Vector3(20,20,20) für Keyframe 1 zeigt die folgende Tabelle das Animationsverhalten mit unterschiedlichen Werten für Direction.

DirectionAnimationsverhalten
NormalAnimation beginnt mit dem Offsetwert Vector3(5,5,5) und wechselt zu Vector3(20,20,20), wobei 3-mal immer ab (5,5,5) wiederholt wird.
ReverseAnimation beginnt im Umgekehrten und Offsetwert (20,20,20) und wechselt zu (5,5,5) und wiederholt sich 3-mal immer ab (20,20,20).
AlternativFür die erste Iteration beginnt die Animation mit dem Offsetwert (5,5,5) und wechselt zu (20,20,20). In der zweiten Iterationsanimation beginnt die Animation mit dem Offsetwert (20,20,20) und wechselt zu (5,5,5). In der dritten und letzten Iteration beginnt die Animation mit offset (5,5,5) und wechselt zu (20,20,20).
AlternateReverseFür die erste Iteration beginnt die Animation mit dem Offsetwert (20,20,20) und wechselt zu (5,5,5). In der zweiten Iteration beginnt die Animation mit dem Offsetwert (5,5,5) und wechselt zu (20, 20, 20). In der dritten und letzten Iteration beginnt die Animation mit offset (20, 20, 20) und wechselt zu (5,5,5).

Gilt für: