言語

ConnectedAnimationService クラス

定義

ConnectedAnimation を表示するプロパティとメソッドを提供するサービスを表します。

public ref class ConnectedAnimationService sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ConnectedAnimationService final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ConnectedAnimationService
Public NotInheritable Class ConnectedAnimationService
継承
Object Platform::Object IInspectable ConnectedAnimationService
属性

Tip

詳細、設計ガイダンス、およびコード例については、「 接続されたアニメーション」を参照してください。

WinUI 3 ギャラリー アプリには、ほとんどの WinUI 3 コントロールと機能の対話型の例が含まれています。 Microsoft Store からアプリを取得するか、GitHub でソース コードを取得します。

この例では、ナビゲーション中に 2 つのページ間で画像をアニメーション化する方法を示します。

SourcePage.xaml/SourcePage.xaml.cs

<Image x:Name="SourceImage"
       Width="200"
       Height="200"
       Stretch="Fill"
       Source="Assets/StoreLogo.png" />
private void NavigateToDestinationPage()
{
    ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("image", SourceImage);
    Frame.Navigate(typeof(DestinationPage));
}

DestinationPage.xaml/DestinationPage.xaml.cs

<Image x:Name="DestinationImage"
       Width="400"
       Height="400"
       Stretch="Fill"
       Source="Assets/StoreLogo.png" />
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    ConnectedAnimation imageAnimation = 
        ConnectedAnimationService.GetForCurrentView().GetAnimation("image");
    if (imageAnimation != null)
    {
        imageAnimation.TryStart(DestinationImage);
    }
}

注釈

ConnectedAnimationService のインスタンスを取得するには、静的 な GetForCurrentView メソッドを呼び出します。

PrepareToAnimate を呼び出すときに、メソッドによって返される新しく作成された ConnectedAnimation に関連付けるキーを指定します。 後でこのキーを使用して 、GetAnimation を呼び出して同じアニメーションを取得できます。 これにより、ページ間で ConnectedAnimation オブジェクトへの参照を手動で渡すことなく、2 つの異なるページ間でアニメーションを接続できます。

ConnectedAnimationService の完全な例については、 Connected アニメーションのサンプル を参照してください。

プロパティ

名前 説明
DefaultDuration

アニメーションを実行する既定の時刻を取得または設定します。

DefaultEasingFunction

アニメーションで使用される既定の CompositionEasingFunction を取得または設定します。

メソッド

名前 説明
GetAnimation(String)

指定したキーを持つアニメーションを返します。

GetForCurrentView()

現在のビューの ConnectedAnimationService のインスタンスを返します。

PrepareToAnimate(String, UIElement)

指定したキーとソース要素に関連付けられている接続されたアニメーションを返します。

適用対象

こちらもご覧ください