OpacityAnimation OpacityAnimation OpacityAnimation OpacityAnimation Class

Definition

Provides methods that enable you to retrieve the parameters of an opacity (fade in or fade out) animation.

public : sealed class OpacityAnimation : IOpacityAnimation, IPropertyAnimation
public sealed class OpacityAnimation : IOpacityAnimation, IPropertyAnimation
Public NotInheritable Class OpacityAnimation Implements IOpacityAnimation, IPropertyAnimation
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows Desktop Extension SDK (introduced v10.0.10240.0)
API contract
Windows.UI.Core.AnimationMetrics.AnimationMetricsContract (introduced v1)

Examples

To obtain an instance of the OpacityAnimation class, you first obtain the collection of animations in the animation description, and then walk that array of animations to find any that are of type opacity. The following example shows this process. The effect and target parameters are assumed to have been previously assigned.


var animationDescription = new Windows.UI.Core.AnimationMetrics.AnimationDescription(effect, target);

var animations = animationDescription.animations;
for (var i = 0; i < animations.size; i++) {
    var animation = animations[i];

    switch (animation.type) {
        case animationMetrics.PropertyAnimationType.scale:
            // Retrieve scale animation metrics
            break;
        case animationMetrics.PropertyAnimationType.translation:
            // Retrieve translation animation metrics
            break;
        case animationMetrics.PropertyAnimationType.opacity:

            // Retrieve scale animation metrics
            break;
    }
}

The following example shows the C# version of the same code.


using Windows.UI.Core.AnimationMetrics;

AnimationDescription animationDescription = new AnimationDescription(effect, target);
foreach (var animation in animationDescription.Animations)
{
    switch (animation.Type)
    {
        case PropertyAnimationType.Scale:
            {
                ScaleAnimation scale = animation as ScaleAnimation;
                // Retrieve scale animation metrics.
            }
            break;
        case PropertyAnimationType.Translation:
            {
                TranslationAnimation scale = animation as TranslationAnimation;
                // Retrieve translation animation metrics.
            }
            break;
        case PropertyAnimationType.Opacity:
            {
                OpacityAnimation opacity = animation as OpacityAnimation;
                // Retrieve opacity animation metrics.
            }
            break;
    }
}

Remarks

The timing controls Control1 and Control2 specify the location of the first and second control points of a cubic Bézier curve. These two points have the same meaning as they do in the CSS transition-timing-function property. Control point zero is always (0,0) and control point three is always (1,1). The coordinates of Control1 and Control2 are always in the range 0 to 1, inclusive.

On the resulting Bézier curve, the x-coordinate represents time and the y-coordinate represents progress. The raw curve from (0,0) to (1,1) is scaled to match the actual duration and range of the animated transition, such that x=0 is the starting time of the transform, x=1 is the ending time, y=0 is the initial value of the animated property, and y=1 is the final value. Values of x and y between 0 and 1 represent corresponding intermediate values of time and the animation.

Properties

Control1 Control1 Control1 Control1

Gets the location of the first control point for the cubic Bézier curve that describes how the opacity should animate over time.

public : Point Control1 { get; }
public Point Control1 { get; }
Public ReadOnly Property Control1 As Point
var point = opacityAnimation.control1;
Value
Point Point Point Point

The location of the control point.

See Also

Control2 Control2 Control2 Control2

Gets the location of the second control point for the cubic Bézier curve that describes how the opacity should animate over time.

public : Point Control2 { get; }
public Point Control2 { get; }
Public ReadOnly Property Control2 As Point
var point = opacityAnimation.control2;
Value
Point Point Point Point

The location of the control point.

See Also

Delay Delay Delay Delay

Gets the amount of time between when the opacity animation is instructed to begin and when that animation actually begins to draw.

public : TimeSpan Delay { get; }
public TimeSpan Delay { get; }
Public ReadOnly Property Delay As TimeSpan
var timeSpan = opacityAnimation.delay;
Value
TimeSpan TimeSpan TimeSpan TimeSpan

The amount of time to delay before starting the opacity animation.

Remarks

This delay is in addition to any StaggerDelay applied to the parent AnimationDescription. For instance, if a transition is scheduled through the application of StaggerDelay and StaggerDelayFactor to begin at time t=200 ms and this delay is set to 250 ms, then the transition will actually begin to animate at 450 ms.

See Also

Duration Duration Duration Duration

Gets the amount of time over which the opacity animation should be performed. This does not include the delay.

public : TimeSpan Duration { get; }
public TimeSpan Duration { get; }
Public ReadOnly Property Duration As TimeSpan
var timeSpan = opacityAnimation.duration;
Value
TimeSpan TimeSpan TimeSpan TimeSpan

The duration of the animation.

Remarks

The duration can be 0, in which case the opacity is instantly set to its final value and no animation is shown.

See Also

FinalOpacity FinalOpacity FinalOpacity FinalOpacity

Gets the object's final opacity.

public : float FinalOpacity { get; }
public float FinalOpacity { get; }
Public ReadOnly Property FinalOpacity As float
var float = opacityAnimation.finalOpacity;
Value
float float float float

The final opacity. A value of 0.0 represents full transparency and a value of 1.0 represents full opacity.

See Also

InitialOpacity InitialOpacity InitialOpacity InitialOpacity

Gets the object's initial opacity.

public : IReference<float> InitialOpacity { get; }
public Nullable<float> InitialOpacity { get; }
Public ReadOnly Property InitialOpacity As Nullable<float>
var nullable = opacityAnimation.initialOpacity;
Value
IReference<float> Nullable<float> Nullable<float> Nullable<float>

The initial opacity, if any. A value of 0.0 represents full transparency and a value of 1.0 represents full opacity.

Remarks

This property's value might not be set when this method is called. In that case, the object's current opacity should be used as the starting point for the animation. If the value is not set and the object is hidden at the beginning of the animation, then the initial opacity is 0.0. If the value is not set and the object is visible at the beginning of the animation, then the object's current opacity should be used as the initial opacity.

See Also

Type Type Type Type

Gets the type of animation represented by this object.

public : PropertyAnimationType Type { get; }
public PropertyAnimationType Type { get; }
Public ReadOnly Property Type As PropertyAnimationType
var propertyAnimationType = opacityAnimation.type;

Remarks

The PropertyAnimation object can be cast to the derived object described by its type. See PropertyAnimationType for a list of types and their corresponding objects.

See Also

See Also