CompositionScopedBatch Class


An explicitly created group of active animations or effects.

public ref class CompositionScopedBatch sealed : CompositionObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
class CompositionScopedBatch final : CompositionObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
public sealed class CompositionScopedBatch : CompositionObject
Public NotInheritable Class CompositionScopedBatch
Inherits CompositionObject
Windows.Foundation.Metadata.ContractVersionAttribute Windows.Foundation.Metadata.MarshalingBehaviorAttribute Windows.Foundation.Metadata.ThreadingAttribute Windows.Foundation.Metadata.WebHostHiddenAttribute


Scoped Batch

// The Green Square's completion events for the Offset and Opacity animations are aggregated
// The Rotation animation completion event is not aggregated
// When the aggregated events are completed OnBatchCompleted method is executed
public void BatchAnimations()
    // Create a Scoped batch to capture animation completion events
    _batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

    // Executing the Offset animation and aggregating completion event

    // Suspending to exclude the following Rotation animation from the batch

    // Executing the Rotation animation 

    // Resuming the batch to collect additional animations

    // Executing the Opacity animation and aggregating completion event

    // Batch is ended and no objects can be added

    // Method triggered when batch completion event fires
    _batch.Completed += OnBatchCompleted;


Represents a group of active animations or effects, and triggers a callback when all members of the group have completed. A CompositionScopedBatch is explicitly created and is used to designate specific objects to be included in a single scoped batch.

Multiple CompositionScopedBatch instances can be created and objects can be aggregated in multiple batches at the same time.


To aggregate a specific group of animations or target a single animation’s completion event, you create a scoped batch. A scoped batch is explicitly created using Compositor.CreateScopedBatch and is used to designate specific objects to be included in a single batch. A scoped batch can be created on any thread and is not tied to the composition thread. Scoped batches will only aggregate objects within the thread it is created.

CompositionScopedBatch myScopedBatch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

Suspend and resume

After creating a scoped batch, all started animations aggregate until the batch is explicitly suspended or ended using the Suspend or End function.

CompositionScopedBatch may be explicitly paused with Suspend in order to exclude objects from that batch. When a batch is suspended it can be reopened by calling Resume. Calling the Suspend function stops aggregating animation end states until Resume is called. This allows you to explicitly exclude content from a given batch.

In the example below, the animation targeting the Offset property of VisualA will not be included in the batch:

VisualA.StartAnimation("Offset", myAnimation);


A CompositionScopedBatch must be explicitly closed using End. Once it has been closed it cannot be suspended or resumed again. In order to complete your batch you must call End(). Without an End call, the batch will remain open forever-collecting objects.

The following code snippet and diagram shows an example of how the batch will aggregate animations to track end states.

Note that in this example, Animations 1, 3, and 4 will have end states tracked by this Batch, but Animation 2 will not.

CompositionScopedBatch myScopedBatch = 	_compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
// Start Animation1
// Start Animation2 
// Start Animation3
// Start Animation4

The scoped batch contains animation one, animation three, and animation four while animation two is excluded from the scoped batch

Batching a single animation's completion event

If you want to know when a single animation ends, you need to create a scoped batch that will include just the animation you are targeting.

For example:

CompositionScopedBatch myScopedBatch = 	_compositor.CreateScopedBatch(CompositionBatchTypes.Animation);
Visual.StartAnimation("Opacity", myAnimation);

Retrieving a batch's completion event

When batching an animation or multiple animations, you will retrieve the batch’s completion event the same way. You register the event-handling method for the Completed event of the targeted batch.

myScopedBatch.Completed += OnBatchCompleted;

Batch states

There are two properties you can use to determine the state of an existing batch; IsActive and IsEnded.

The IsActive property returns true if a targeted batch is open to aggregating animations. IsActive will return false when a batch is suspended or ended.

The IsEnded property returns true when you cannot add an animation to that specific batch. A batch will be ended when you call explicitly call End for a specific batch.



A string to associate with the CompositionObject.

(Inherited from CompositionObject)

The Compositor used to create this CompositionObject.

(Inherited from CompositionObject)

Gets the DispatcherQueue for the CompostionObject.

(Inherited from CompositionObject)

The collection of implicit animations attached to this object.

(Inherited from CompositionObject)

Indicates whether the CompositionScopedBatch is currently opened for objects to be aggregated.


Indicates whether the CompositionScopedBatch has been closed and can no longer accept changes.


The collection of properties associated with the CompositionObject.

(Inherited from CompositionObject)



Closes the CompositionObject and releases system resources.

(Inherited from CompositionObject)

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

(Inherited from CompositionObject)

Closes the CompositionScopedBatch. Once the CompositionScopedBatch has been closed it cannot be suspended or resumed again.

PopulatePropertyInfo(String, AnimationPropertyInfo)

Defines a property that can be animated.

(Inherited from CompositionObject)

Resumes aggregating objects in the CompositionScopedBatch.

StartAnimation(String, CompositionAnimation)

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

(Inherited from CompositionObject)

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.

(Inherited from CompositionObject)

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

(Inherited from CompositionObject)

Stops an animation group.

(Inherited from CompositionObject)

Suspends aggregating objects in the CompositionScopedBatch.


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

(Inherited from CompositionObject)



Event triggered once all animations and effects in the CompositionScopedBatch have completed.

Applies to

See also