IAnimatedVisualSource2 Interface

Definition

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

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

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 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.

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

Methods

SetColorProperty(String, Color)

Sets a color for the animated visual.

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TryCreateAnimatedVisual(Compositor, Object)

Attempts to create an instance of an animated visual.

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

(Inherited from IAnimatedVisualSource)

Applies to