共用方式為


IAnimatedVisualSource2 介面

定義

其他物件可以使用的動畫 視覺效果 ,例如 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
衍生
屬性
實作

範例

本範例會顯示並動畫顯示實作 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);
}

備註

呼叫 IAnimatedVisualSource.TryCreateAnimatedVisual (Compositor、Object) 方法來擷取 IAnimatedVisual 物件。 然後,這 IAnimatedVisual 可用來取得 Composition.Visual,其可以使用 ElementCompositionPreview 的 方法來新增至 XAML 元素樹狀結構。

屬性

Markers

取得集合,提供標記名稱與動畫中播放位置的對應。

方法

SetColorProperty(String, Color)

設定動畫視覺效果的色彩。

TryCreateAnimatedVisual(Compositor, Object)

嘗試建立動畫視覺效果。

(繼承來源 IAnimatedVisualSource)

適用於