IAnimatedVisualSource2 Interface

Definition

An animated Visual that can be used by other objects, such as an AnimatedIcon. Extends IAnimatedVisualSource

public interface class IAnimatedVisualSource2 : IAnimatedVisualSource
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.XamlContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(440095655, 43262, 22945, 181, 68, 67, 164, 217, 200, 30, 242)]
struct IAnimatedVisualSource2 : IAnimatedVisualSource
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.XamlContract), 65536)]
[Windows.Foundation.Metadata.Guid(440095655, 43262, 22945, 181, 68, 67, 164, 217, 200, 30, 242)]
public interface IAnimatedVisualSource2 : IAnimatedVisualSource
Public Interface IAnimatedVisualSource2
Implements IAnimatedVisualSource
Derived
Attributes
Implements

Examples

This example displays and animates an object that implements IAnimatedVisualSource2:

void AddVisualAndShowStartAnimation(
    const winrt::Border& element,
    const& winrt::IAnimatedVisualSource2 source,
    const winrt::hstring& initialState,
    const winrt::hstring& steadyState,
    const winrt::Color& themeColor )
{
    winrt::IAnimatedVisual animatedVisual = source.TryCreateAnimatedIconVisual();

    // Find the playback positions in the animation of the two states
    auto const markers = source.Markers();
    auto const fromProgress = static_cast<float>(markers.Lookup(initialState));
    auto const toProgress = static_cast<float>(markers.Lookup(steadyState));

    // Set the theme color as the animated visual's foreground.
    source.SetColorProperty("Foreground", themeColor);

    // Helper that uses TryCreateAnimatedVisual to add the source to the XAML element tree.
    // See IAnimatedVisualSource.TryCreateAnimatedVisual for more information.
    AddVisualToElement(element, animatedVisual);

    // Helper to play an animation.
    // See IAnimatedVisual for more information.
    PlaySegment(animatedVisual.RootVisual(), fromProgress, toProgress);
}

Remarks

Call the IAnimatedVisualSource.TryCreateAnimatedVisual(Compositor, Object) method to retrieve an IAnimatedVisual object. This IAnimatedVisual can then be used to get a Composition.Visual, which can be added to a XAML element tree using the methods of ElementCompositionPreview.

Properties

Markers

Gets a collection that provides a mapping of marker names to playback positions in the animation.

Methods

SetColorProperty(String, Color)

Sets a color for the animated visual.

TryCreateAnimatedVisual(Compositor, Object)

Attempts to create an animated visual.

(Inherited from IAnimatedVisualSource)

Applies to