ImplicitAnimationCollection Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A collection of animations triggered when a condition is met.
public ref class ImplicitAnimationCollection sealed : CompositionObject, IIterable<IKeyValuePair<Platform::String ^, ICompositionAnimationBase ^> ^>, IMap<Platform::String ^, ICompositionAnimationBase ^>
/// [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)]
class ImplicitAnimationCollection final : CompositionObject, IIterable<IKeyValuePair<winrt::hstring, ICompositionAnimationBase const&>>, IMap<winrt::hstring, ICompositionAnimationBase const&>
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
class ImplicitAnimationCollection final : CompositionObject, IIterable<IKeyValuePair<winrt::hstring, ICompositionAnimationBase const&>>, IMap<winrt::hstring, ICompositionAnimationBase const&>
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ImplicitAnimationCollection : CompositionObject, IDictionary<string,ICompositionAnimationBase>, IEnumerable<KeyValuePair<string,ICompositionAnimationBase>>
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public sealed class ImplicitAnimationCollection : CompositionObject, IDictionary<string,ICompositionAnimationBase>, IEnumerable<KeyValuePair<string,ICompositionAnimationBase>>
Public NotInheritable Class ImplicitAnimationCollection
Inherits CompositionObject
Implements IDictionary(Of String, ICompositionAnimationBase), IEnumerable(Of KeyValuePair(Of String, ICompositionAnimationBase))
- Inheritance
- Attributes
- Implements
-
IDictionary<String,ICompositionAnimationBase> IMap<Platform::String,ICompositionAnimationBase> IMap<winrt::hstring,ICompositionAnimationBase> IIterable<IKeyValuePair<K,V>> IEnumerable<KeyValuePair<K,V>> IEnumerable<KeyValuePair<String,ICompositionAnimationBase>> IIterable<IKeyValuePair<Platform::String,ICompositionAnimationBase>> IIterable<IKeyValuePair<winrt::hstring,ICompositionAnimationBase>>
Examples
class PropertyAnimation
{
PropertyAnimation(Compositor compositor, SpriteVisual heroVisual, SpriteVisual listVisual)
{
// Define ImplicitAnimationCollection
ImplicitAnimationCollection implicitAnimations = compositor.CreateImplicitAnimationCollection();
// Trigger animation when the “Offset” property changes.
implicitAnimations["Offset"] = CreateAnimation(compositor);
// Assign ImplicitAnimations to a visual. Unlike Visual.Children,
// ImplicitAnimations can be shared by multiple visuals so that they
// share the same implicit animation behavior (same as Visual.Clip).
heroVisual.ImplicitAnimations = implicitAnimations;
// ImplicitAnimations can be shared among visuals
listVisual.ImplicitAnimations = implicitAnimations;
listVisual.Offset = new Vector3(20f, 20f, 20f);
}
Vector3KeyFrameAnimation CreateAnimation(Compositor compositor)
{
Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation();
animation.InsertExpressionKeyFrame(0f, "this.StartingValue");
animation.InsertExpressionKeyFrame(1f, "this.FinalValue");
animation.Target = “Offset”;
animation.Duration = TimeSpan.FromSeconds(0.25);
return animation;
}
}
Remarks
Implicit animations let you drive animations by specifying trigger conditions rather than requiring the manual definition of animation behavior. They help decouple animation start logic from core app logic. You define animations and the events that should trigger these animations. The compositor then executes the set animations when the appropriate trigger conditions are met.
Triggers
Condition act as triggers for ImplicitAnimationCollection. These triggers are CompositionObject animatable properties. For Windows 10 Anniversary Update only Visual animatable properties are supported as triggers.
this.FinalValue
This is a special keyword within “Composition Expressions system” that developers can use to template their animations and let the platform bind it to the target property’s API value.
Animations will support this.FinalValue keyword as a valid keyword to signify the final value of a target property for an animation.
- Implicit Animations – The this.FinalValue will be set to the last value that the corresponding target property was directly assigned to. For instance, when the visual’s Offset property is directly assigned to, implicit animations that target the Offset property will have this.FinalValue set to the new Offset value, of type Vector3. Other implicit animations that target different properties, say Size , will still be able to use the this.FinalValue in the template, and in that case this.FinalValue will be set to the current value of the Size property, of type Vector2. Note that in the latter case this.FinalValue will be the same as this.StartingValue . This provides a well-defined behavior and makes it easy for the developers to author the animation templates as this.FinalValue will always be resolved to a valid value, regardless of which property has triggered the change.
- Explicit Animations: By default it will have the same behavior as the implicit animation’s case, where this.FinalValue will be set to the last value that the property was directly set to. For example, animations that target the Size property will have this.FinalValue resolved to the last known Size value on the API layer. In other words, this.FinalValue will be the same as this.StartingValue . The developer will be able to override that behavior and set this.FinalValue to a different value by setting it as an animation parameter explicitly.
Events and target properties for ImplicitAnimationCollection and CompositionAnimationGroup
ImplicitAnimationCollection lets you add triggers which implicit animation will monitor for changes and kick off related animations as provided by the developer. ImplicitAnimationCollection supports all Visual animatable properties which are also used as target properties for animations. Target has to be defined on the animation or it will throw an exception.
implicitAnimationCollection[“Offset”] = offsetAnimationGroup;
CompositionAnimationGroup contains a list of CompositionAnimation where they can be triggered as a single logical unit. Each CompositionAnimation in the group should have the target property set.
CompositionAnimationGroup.Add(opacityKeyFrameAnimation);
CompositionAnimationGroup.Insert(sizeKeyFrameAnimation);
ImplicitAnimationCollection supports the following properties on Visual:
- AnchorPoint
- CenterPoint
- Offset
- Opacity
- Orientation
- RotationAngle
- RotationAngleInDegrees
- RotationAxis
- Scale
- Size If the same value is set again then animation will not occur as there was not delta between previous and new value.
Properties
Comment |
A string to associate with the CompositionObject. (Inherited from CompositionObject) |
Compositor |
The Compositor used to create this CompositionObject. (Inherited from CompositionObject) |
DispatcherQueue |
Gets the DispatcherQueue for the CompositionObject. (Inherited from CompositionObject) |
ImplicitAnimations |
The collection of implicit animations attached to this object. (Inherited from CompositionObject) |
Properties |
The collection of properties associated with the CompositionObject. (Inherited from CompositionObject) |
Size |
The size of the collection. |
Methods
Clear() |
Removes all animations from the collection. |
Close() |
Closes the CompositionObject and releases system resources. (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 collection. |
GetView() |
Returns a map view of the collection. |
HasKey(String) |
Returns a boolean indicating whether the collection contains the specified key. |
Insert(String, ICompositionAnimationBase) |
Inserts an animation into the collection. |
Lookup(String) |
Retrieves the animation associated with the specified property. |
PopulatePropertyInfo(String, AnimationPropertyInfo) |
Defines a property that can be animated. (Inherited from CompositionObject) |
Remove(String) |
Removes the specified animation from the collection. |
StartAnimation(String, CompositionAnimation, AnimationController) |
Connects an animation with the specified property of the object and starts the animation. (Inherited from CompositionObject) |
StartAnimation(String, CompositionAnimation) |
Connects an animation with the specified property of the object and starts the animation. (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. (Inherited from CompositionObject) |
StopAnimation(String) |
Disconnects an animation from the specified property and stops the animation. (Inherited from CompositionObject) |
StopAnimationGroup(ICompositionAnimationBase) |
Stops an animation group. (Inherited from CompositionObject) |
TryGetAnimationController(String) |
Returns an AnimationController for the animation running on the specified property. (Inherited from CompositionObject) |