CompositionAnimationGroup Class

Definition

Defines a group of animations.

CompositionAnimationGroup provides a way to group CompositionAnimation s in a list which will be started at the same time when StartAnimationGroup is called on CompositionObject. All CompositionAnimation in CompositionAnimationGroup need to assign a value to the Target property in the animation itself. CompositionAnimationGroup can also be associated with ImplicitAnimationCollection as an animation that gets executed as a result of a trigger.

Equivalent WinUI class: Microsoft.UI.Composition.CompositionAnimationGroup.

public ref class CompositionAnimationGroup sealed : CompositionObject, IIterable<CompositionAnimation ^>, ICompositionAnimationBase
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CompositionAnimationGroup final : CompositionObject, IIterable<CompositionAnimation>, ICompositionAnimationBase
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class CompositionAnimationGroup : CompositionObject, IEnumerable<CompositionAnimation>, ICompositionAnimationBase
Public NotInheritable Class CompositionAnimationGroup
Inherits CompositionObject
Implements ICompositionAnimationBase, IEnumerable(Of CompositionAnimation)
Inheritance
CompositionAnimationGroup
Attributes
Implements

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Examples

Implicit Animations usage of Animation Group

class PropertyAnimation 
{ 
  PropertyAnimation(Compositor compositor, SpriteVisual heroVisual, Vector2KeyFrameAnimation sizeAnimation, Vector3KeyFrameAnimation OffsetAnimation) 
  { 
  // Define ImplicitAnimations 
  ImplicitAnimationCollection implicitAnimations =  compositor.CreateImplicitAnimationCollection(); 

  // Create AnimationGroup 
  CompositionAnimationGroup animationGroup = compositor.CreateAnimationGroup(); 

  animationGroup.Add(sizeAnimation); 
  animationGroup.Add(offsetAnimation); 

  // Associate the given animation group with the “Size” Change 
  implicitAnimationsCollection["Size"] = animationGroup; 

  // assign ImplicitAnimationCollection to visual 
  heroVisual.ImplicitAnimations = implicitAnimations;  

  // Set the CenterPoint so that rotation will be around the center 
  heroVisual.CenterPoint = new Vector3((heroVisual.Size.X/2.0f), (heroVisual.Size.Y/2.0f), 0.0f); 
} 

StartAnimationGroup

class PropertyAnimation 
{ 
  PropertyAnimation(Compositor compositor, SpriteVisual heroVisual, Vector2KeyFrameAnimation sizeAnimation, Vector3KeyFrameAnimation OffsetAnimation) 
  { 
    // Create AnimationGroup 
    CompositionAnimationGroup animationGroup =  
    compositor.CreateAnimationGroup(); 

    animationGroup.Add(sizeAnimation); 
    animationGroup.Add(offsetAnimation); 
    heroVisual.StartAnimationGroup(animationGroup); 
  }
} 

Remarks

CompositionAnimationGroup is a list of CompositionAnimation. Different CompositionAnimation s can be added to the group and can be used in ImplicitAnimationCollection or start the group using Visual.StartAnimationGroup(CompositionAnimationGroup).

All the CompositionAnimation s in CompositionAnimationGroup should have target property assigned as part of animation template.

If CompositionAnimationGroup is changed while iterating the animations in the group, an InvalidOperationException will be thrown.

Use the CompostionObject.StartAnimationGroup and CompostionObject.StopAnimationGroup methods to start and stop the animation group.

Properties

Comment

A string to associate with the CompositionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.Comment.

(Inherited from CompositionObject)
Compositor

The Compositor used to create this CompositionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.Compositor.

(Inherited from CompositionObject)
Count

The number of animations in the group.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionAnimationGroup.Count.

Dispatcher

The dispatcher for the CompositionObject.

(Inherited from CompositionObject)
DispatcherQueue

Gets the DispatcherQueue for the CompostionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.DispatcherQueue.

(Inherited from CompositionObject)
ImplicitAnimations

The collection of implicit animations attached to this object.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.ImplicitAnimations.

(Inherited from CompositionObject)
Properties

The collection of properties associated with the CompositionObject.

Equivalent WinUI property: Microsoft.UI.Composition.CompositionObject.Properties.

(Inherited from CompositionObject)

Methods

Add(CompositionAnimation)

Adds an animation to the animation group.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionAnimationGroup.Add.

Close()

Closes the CompositionObject and releases system resources.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.Close.

(Inherited from CompositionObject)
ConnectAnimation(String, CompositionAnimation)

Connects and animation.

(Inherited from CompositionObject)
DisconnectAnimation(String)

Disconnects an animation.

(Inherited from CompositionObject)
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from CompositionObject)
First()

Retrieves the first animation in the group.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionAnimationGroup.First.

PopulatePropertyInfo(String, AnimationPropertyInfo)

Defines a property that can be animated.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.PopulatePropertyInfo.

(Inherited from CompositionObject)
Remove(CompositionAnimation)

Removes an animation from the animation group.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionAnimationGroup.Remove.

RemoveAll()

Removes all animations from the group.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionAnimationGroup.RemoveAll.

StartAnimation(String, CompositionAnimation)

Connects an animation with the specified property of the object and starts the animation.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StartAnimation.

(Inherited from CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

Starts an animation group.

The StartAnimationGroup method on CompositionObject lets you start CompositionAnimationGroup. All the animations in the group will be started at the same time on the object.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StartAnimationGroup.

(Inherited from CompositionObject)
StopAnimation(String)

Disconnects an animation from the specified property and stops the animation.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StopAnimation.

(Inherited from CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

Stops an animation group.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.StopAnimationGroup.

(Inherited from CompositionObject)
TryGetAnimationController(String)

Returns an AnimationController for the animation running on the specified property.

Equivalent WinUI method: Microsoft.UI.Composition.CompositionObject.TryGetAnimationController.

(Inherited from CompositionObject)

Applies to

See also