Back to Devexpress

AnimationSelector Class

wpf-devexpress-dot-xpf-dot-windowsui-a46a59b6.md

latest6.1 KB
Original Source

AnimationSelector Class

Represents a base class for objects that provide a custom logic to select a frame animation.

Namespace : DevExpress.Xpf.WindowsUI

Assembly : DevExpress.Xpf.Controls.v25.2.dll

NuGet Package : DevExpress.Wpf.Controls

Declaration

csharp
public class AnimationSelector
vb
Public Class AnimationSelector

The following members return AnimationSelector objects:

Remarks

The AnimationSelector class descentants should be assigned to the NavigationFrame.AnimationSelector and Wizard.AnimationSelector settings. See these properties for details.

Example

The example below shows how to provide a custom storyboard used to render backward and forward navigation for a NavigationFrame. The AnimationSelector‘s SelectStoryboard method override returns a storyboard according to the animation direction.

csharp
using System.Windows.Media.Animation;

public class FrameAnimationSelector : DevExpress.Xpf.WindowsUI.AnimationSelector {
    private Storyboard _BackStoryboard;
    private Storyboard _ForwardStoryboard;
    public Storyboard ForwardStoryboard {
        get { return _ForwardStoryboard; }
        set { _ForwardStoryboard = value; }
    }
    public Storyboard BackStoryboard {
        get { return _BackStoryboard; }
        set { _BackStoryboard = value; }
    }
    protected override Storyboard SelectStoryboard(DevExpress.Xpf.WindowsUI.FrameAnimation animation) {
        return animation.Direction == DevExpress.Xpf.WindowsUI.AnimationDirection.Forward ? ForwardStoryboard : BackStoryboard;
    }
}
vb
Imports System.Windows.Media.Animation

Public Class FrameAnimationSelector
    Inherits DevExpress.Xpf.WindowsUI.AnimationSelector
    Private _BackStoryboard As Storyboard
    Private _ForwardStoryboard As Storyboard
    Public Property ForwardStoryboard() As Storyboard
        Get
            Return _ForwardStoryboard
        End Get
        Set
            _ForwardStoryboard = value
        End Set
    End Property
    Public Property BackStoryboard() As Storyboard
        Get
            Return _BackStoryboard
        End Get
        Set
            _BackStoryboard = value
        End Set
    End Property
    Protected Overrides Function SelectStoryboard(animation As DevExpress.Xpf.WindowsUI.FrameAnimation) As Storyboard
        Return If(animation.Direction = DevExpress.Xpf.WindowsUI.AnimationDirection.Forward, ForwardStoryboard, BackStoryboard)
    End Function
End Class
xaml
xmlns:dxwui="http://schemas.devexpress.com/winfx/2008/xaml/windowsui" 
xmlns:dxwuin="http://schemas.devexpress.com/winfx/2008/xaml/windowsui/navigation">

<Window.Resources>
    <local:FrameAnimationSelector x:Key="frameAnimationSelector">
        <local:FrameAnimationSelector.BackStoryboard>
            <Storyboard>
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="NewContent.(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                    <SplineDoubleKeyFrame KeyTime="00:00:00.400" Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.500" Storyboard.TargetProperty="NewContentTranslateX" From="1" To="0">
                    <DoubleAnimation.EasingFunction>
                        <CubicEase EasingMode="EaseOut"/>
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="OldContent.(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                    <SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </local:FrameAnimationSelector.BackStoryboard>
        <local:FrameAnimationSelector.ForwardStoryboard>
            <Storyboard>
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="NewContent.(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
                    <SplineDoubleKeyFrame KeyTime="00:00:00.400" Value="1" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.500" Storyboard.TargetProperty="NewContentTranslateX" From="-1" To="0">
                    <DoubleAnimation.EasingFunction>
                        <CubicEase EasingMode="EaseOut"/>
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="OldContent.(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
                    <SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </local:FrameAnimationSelector.ForwardStoryboard>
    </local:FrameAnimationSelector>
</Window.Resources>

<dxwui:NavigationFrame AnimationSelector="{StaticResource frameAnimationSelector}"/>

Inheritance

Object AnimationSelector

See Also

AnimationSelector Members

DevExpress.Xpf.WindowsUI Namespace