ConnectedAnimationService ConnectedAnimationService ConnectedAnimationService Class

Definition

Represents a service that provides properties and methods to display a ConnectedAnimation.

public : sealed class ConnectedAnimationService : IConnectedAnimationService
public sealed class ConnectedAnimationService : IConnectedAnimationService
Public NotInheritable Class ConnectedAnimationService Implements IConnectedAnimationService
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Examples

This example shows how to animate an image between two pages during a navigation.

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);
    }
}

Remarks

To get an instance of ConnectedAnimationService, call the static GetForCurrentView method.

When you call PrepareToAnimate, you supply a key to associate with the newly created ConnectedAnimation returned by the method. You can later use this key to retrieve the same animation by calling GetAnimation. This lets you connect the animation between two different pages without having to manually pass the reference to the ConnectedAnimation object between pages.

See the Connected animation sample for a complete example of ConnectedAnimationService.

Properties

DefaultDuration DefaultDuration DefaultDuration

Gets or sets the default time that the animation runs.

public : TimeSpan DefaultDuration { get; set; }
public TimeSpan DefaultDuration { get; set; }
Public ReadWrite Property DefaultDuration As TimeSpan
Value
TimeSpan TimeSpan TimeSpan

The default time that the animation runs.

DefaultEasingFunction DefaultEasingFunction DefaultEasingFunction

Gets or sets the default CompositionEasingFunction used by the animation.

public : CompositionEasingFunction DefaultEasingFunction { get; set; }
public CompositionEasingFunction DefaultEasingFunction { get; set; }
Public ReadWrite Property DefaultEasingFunction As CompositionEasingFunction

Methods

GetAnimation(String) GetAnimation(String) GetAnimation(String)

Returns the animation with the specified key.

public : ConnectedAnimation GetAnimation(Platform::String key)
public ConnectedAnimation GetAnimation(String key)
Public Function GetAnimation(key As String) As ConnectedAnimation
Parameters
key
Platform::String String String

The key for the animation.

Returns

The animation with the specified key; or null if no animation has been prepared for that key, or if the animation is no longer active.

Remarks

A ConnectedAnimation is no longer active when:

  • It has been canceled.
  • The animation has completed.
  • The source has expired (PrepareToAnimate was called and then the animation was not started for ~2 seconds).

GetForCurrentView() GetForCurrentView() GetForCurrentView()

Returns an instance of ConnectedAnimationService for the current view.

public : static ConnectedAnimationService GetForCurrentView()
public static ConnectedAnimationService GetForCurrentView()
Public Static Function GetForCurrentView() As ConnectedAnimationService
Returns

PrepareToAnimate(String, UIElement) PrepareToAnimate(String, UIElement) PrepareToAnimate(String, UIElement)

Returns a connected animation that's associated with the specified key and source element.

public : ConnectedAnimation PrepareToAnimate(Platform::String key, UIElement source)
public ConnectedAnimation PrepareToAnimate(String key, UIElement source)
Public Function PrepareToAnimate(key As String, source As UIElement) As ConnectedAnimation
Parameters
key
Platform::String String String

The key for the animation.

source
UIElement UIElement UIElement

The element that is animated out of view.

Returns

The animation with the specified key.

Remarks

When you call PrepareToAnimate, you supply a key to associate with the newly created ConnectedAnimation returned by the method. You can later use this key to retrieve the same animation by calling GetAnimation. This lets you connect the animation between two different pages without having to manually pass the reference to the ConnectedAnimation object between pages.

See Also