CompositionObject.StartAnimation(String, CompositionAnimation) CompositionObject.StartAnimation(String, CompositionAnimation) CompositionObject.StartAnimation(String, CompositionAnimation) CompositionObject.StartAnimation(String, CompositionAnimation) Method

Definition

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

public : void StartAnimation(Platform::String propertyName, CompositionAnimation animation)
void StartAnimation(winrt::hstring propertyName, CompositionAnimation animation) const;
public void StartAnimation(String propertyName, CompositionAnimation animation)
Public Sub StartAnimation(propertyName As String, animation As CompositionAnimation)

Parameters

propertyName
String String

The property to associate the animation with.

animation
CompositionAnimation CompositionAnimation

The animation to associate with the specified property.

Additional features and requirements

Device family
Windows 10 (introduced v10.0.10586.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Examples


void AnimatingVisualOffset(Visual targetVisual) 
{ 
    var animation = _compositor.CreateVector3KeyFrameAnimation(); 

    // 
    // Define specific easing functions. 
    // 


    var linear = _compositor.CreateLinearEasingFunction(); 

    var easeIn = _compositor.CreateCubicBezierEasingFunction( 
            new Vector2(0.5f, 0.0f), new Vector2(1.0f, 1.0f)); 

    var easeOut = _compositor.CreateCubicBezierEasingFunction( 
            new Vector2(0.0f, 0.0f), new Vector2(0.5f, 1.0f)); 

    // 
    // Add a set of key frames to describe how the Offset should change over time.   
    // 

    animation.InsertKeyFrame(0.00f, new Vector3(100.0f, 100.0f, 0.0f)); 
    animation.InsertKeyFrame(0.25f, new Vector3(300.0f, 100.0f, 0.0f), easeIn); 
    animation.InsertKeyFrame(0.50f, new Vector3(300.0f, 300.0f, 0.0f), linear); 
    animation.InsertKeyFrame(0.75f, new Vector3(100.0f, 300.0f, 0.0f), linear); 
    animation.InsertKeyFrame(1.00f, new Vector3(100.0f, 100.0f, 0.0f), easeOut); 

    // 
    // The animation curve defined by the key frames will scale to match the duration. 
    // 

    animation.Duration = TimeSpan.FromMilliseconds(4000); 

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

Remarks

If an animation is already bound to an object's property when StartAnimation is called, the previous applied animation will be disconnected and the new animation will be assigned. Similarly, setting the property directly will cause the previous animation to be disconnected and the new property value will take effect.

The following table shows the list of animatable properties:

ObjectProperty NameProperty Type
@Windows.UI.Composition.Visual?text=Visual @Windows.UI.Composition.Visual.AnchorPoint?text=AnchorPoint Vector2
@Windows.UI.Composition.Visual.CenterPoint?text=CenterPoint Vector3
@Windows.UI.Composition.Visual.Offset?text=Offset Vector3
@Windows.UI.Composition.Visual.Opacity?text=Opacity Scalar
@Windows.UI.Composition.Visual.Orientation?text=Orientation Vector4
@Windows.UI.Composition.Visual.RotationAngle?text=RotationAngle Scalar
@Windows.UI.Composition.Visual.RotationAxis?text=RotationAxis Vector3
@Windows.UI.Composition.Visual.Size?text=Size Vector2
@Windows.UI.Composition.Visual.TransformMatrix?text=TransformMatrix Matrix4x4
@Windows.UI.Composition.InsetClip?text=InsetClip @Windows.UI.Composition.InsetClip.BottomInset?text=BottomInset Scalar
@Windows.UI.Composition.InsetClip.LeftInset?text=LeftInset Scalar
@Windows.UI.Composition.InsetClip.RightInset?text=RightInset Scalar
@Windows.UI.Composition.InsetClip.TopInset?text=TopInset Scalar
@Windows.UI.Composition.CompositionColorBrush?text=CompositionColorBrush @Windows.UI.Composition.CompositionColorBrush.Color?text=Color Windows.UI.Color
@Windows.UI.Composition.CompositionPropertySet?text=CompositionPropertySet Set of properties specified by the developer.

In addition, properties of some effects under the CompositionEffectBrush object can be animated:

Effect NameProperty NameProperty Type
SaturationEffectSaturationScalar
ColorSourceEffectColorVector4
ArithmeticCompositeOffsetScalar
Source1AmountScalar
Source2AmountScalar
MultiplyAmountScalar
Transform2DTransformMatrixMatrix3x2
ContrastEffectContrastFloat
ExposureEffectExposureFloat
HueRotationEffectAngleFloat
SepiaEffectIntensityFloat
TemperatureAndTintEffectTemperatureFloat
TintFloat
GammaTransferEffectRedAmplitudeFloat
RedExponentFloat
RedOffsetFloat
GreenAmplitudeFloat
GreenExponentFloat
GreenOffsetFloat
BlueAmplitudeFloat
BlueExponentFloat
BlueOffsetFloat
AlphaAmplitudeFloat
AlphaExponentFloat
AlphaOffsetFloat