Giter Site home page Giter Site logo

xamlflair / xamlflair Goto Github PK

View Code? Open in Web Editor NEW
789.0 16.0 68.0 63.24 MB

XamlFlair is an animation library for UWP, WPF, and Uno, built to facilitate Xaml animations using only attached properties.

License: MIT License

C# 96.76% Smalltalk 2.68% Batchfile 0.57%
xamlflair uwp wpf xaml uwp-apps animation windows-10 windows uno uno-platform

xamlflair's Introduction

XamlFlair

The goal of the XamlFlair library is to ease the implementation of common animations and allow a developer to easily add a single or combined set of animations with just a few lines of Xaml.

Sample App

Showcase

Sekuence Puzzle Game
Sekuence

Supporting Me

If you would like to support my work with a few coffees, you can do it here: Buy Me A Coffee. Your help allows me to continue to spend time on this project and continue to maintain and update it with new features when possible. Thanks in advance!

Contents

Install from Nuget

Platform Package NuGet
UWP XamlFlair.UWP UWPNuGetShield
WPF XamlFlair.WPF WPFNuGetShield
Uno XamlFlair.Uno UNONuGetShield

To install XamlFlair, run the following command in the Package Manager Console:

UWP:

Install-Package XamlFlair.UWP

Your app must target a minimum of Windows 10 version 1809 (build 17763)

WPF:

Install-Package XamlFlair.WPF

Uno:

Install-Package XamlFlair.Uno

Your UWP app must target a minimum of Windows 10 version 1809 (build 18362)

Features Overview

Feature UWP WPF UWP (Uno) iOS (Uno) Android (Uno) Wasm (Uno) EXPERIMENTAL
Animation System Composition Storyboards Storyboards Storyboards Storyboards Storyboards
Transform Type N/A TransformGroup CompositeTransform CompositeTransform CompositeTransform CompositeTransform
DefaultAnimations.xaml - - - - -
TransformOn - - - - -
Compound Animations
Relative Translations
Repeating Animations
Events & Bindings
Primary/Secondary Completion Commands
StartWith
AllowOpacityReset - - - - -
ClipToBounds N/A
Animated Lists
Blur Effect - - - -
Saturation Effect - - - - -
Tint Effect - - - - -
Color Animations -
Perspective Rotations (Swivel) - - - - -
Debugging Animations -

Basic Concepts

The basic concept of XamlFlair is based on animations that are categorized as From and To. Any UI element that consists of a From animation will start with one or more arbitrary values, and complete using the default value of the corresponding property. Any UI element that consists of a To animation will start in its current state and animate to one or more arbitrary values.

Example of a From animation (a UI element translating to the default value of a Translation (0)):

From animation

Example of a To animation (a UI element sliding away from its current state):

To animation

Note: It's important to note there is an exception to this rule for Color Animations, which is explained in the Base Animation Types section.

Usage

To begin, you need to have the following Xaml namespace reference:

UWP and Uno:

xmlns:xf="using:XamlFlair"

WPF:

xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"

From here on, it's a simple matter of setting an attached property to any FrameworkElement that needs an animation:

<Border xf:Animations.Primary="{StaticResource FadeIn}" />

Note: If your FrameworkElement defines a CompositeTransform in your Xaml, it will be altered during the animation process.

Note: The use of StaticResource is to reference global common animations, which is discussed in the next section.

Base Animation Types

Fade

Fade animation

Warning: Be careful when animating FadeTo since the element remains in the Visual Tree if the Visibility is Visible. There may be cases where you'll need to manually manage IsHitTestVisible to allow the user to tap through the element.

Translate

Translation animation

Scale

Scale animation

Rotate

Rotation animation

Blur (UWP and WPF only)

Blur animation

Saturate (UWP only)

Saturate animation

Tint (UWP only)

Tint animation

Color (WPF and Uno only)

Color animation

Note: It's important to note when animating a color using a From animation, the color will animate from a specified value to its current state instead of a default value.

Swivel (UWP only)

Swivel animation

Note: Read the section Perspective Rotations (UWP Only) for further details.

The following lists some notable default values when working with XamlFlair:

  • Kind: FadeTo
  • Duration (milliseconds): 500
  • Easing: Cubic
  • Easing Mode: EaseOut
  • TransformCenterPoint: (0.5, 0.5)
  • Event: Loaded
  • InterElementDelay (milliseconds): 25 (List controls only)
  • TransformOn: Render (WPF only)
  • Saturation: 0.5 (UWP only)
  • Tint: Transparent (UWP only)

Color Animations (WPF And Uno Only)

Color animations require some attention since they are slightly different than the other base type animations. When using either ColorTo and ColorFrom, the following must be done:

  • You can only animate the following properties: Control.Background, Control.Foreground, Control.BorderBrush, Border.Background, Border.BorderBrush, TextBlock.Foreground, Shape.Fill, Shape.Stroke
  • Make sure to set a brush on the corresponding property you intend to animate
  • You must also specify the target property using ColorOn

The following example will animate the Rectangle's Fill from RoyalBlue to DarkGreen:

<xf:AnimationSettings x:Key="SampleColorAnimation"
                      Kind="ColorTo"
                      Color="DarkGreen"
                      ColorOn="Fill" />

<Rectangle Fill="RoyalBlue"
           xf:Animations.Primary="{StaticResource SampleColorAnimation}" />

Overriding the Global Default Values

If you have the need to globally change one of the default animation values (for example, having a default Duration of 750 instead of 500), you can call the OverrideDefaultSettings function in your app's initialization code. The following example changes the default values for Duration and Easing:

XamlFlair.Animations.OverrideDefaultSettings(
    duration: 750,
    easing: EasingType.Quadratic);

Therefore, with the sample code above, every animation will run for 750ms with a quadratic easing.

Using a ResourceDictionary for Base Settings

All common animations should be placed in a global ResourceDictionary (ex: Animations.xaml) and used where needed throughout the app. The goal is to consolidate all the animations into one file with meaningful names so that any developer can understand exactly what animation is applied to a FrameworkElement. Here's a small example of what it looks like:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:xf="using:XamlFlair">

    <x:Double x:Key="PositiveOffset">50</x:Double>
    <x:Double x:Key="NegativeOffset">-50</x:Double>
    <x:Double x:Key="SmallScaleFactor">0.75</x:Double>
    <x:Double x:Key="LargeScaleFactor">1.25</x:Double>

    <xf:AnimationSettings x:Key="FadeIn"
                          Kind="FadeFrom"
                          Opacity="0" />

    <xf:AnimationSettings x:Key="FadeOut"
                          Kind="FadeTo"
                          Opacity="0" />

    <!-- Scale to a larger value -->
    <xf:AnimationSettings x:Key="Expand"
                          Kind="ScaleXTo,ScaleYTo"
                          ScaleX="{StaticResource LargeScaleFactor}"
                          ScaleY="{StaticResource LargeScaleFactor}" />

    <!-- Scale from a larger value -->
    <xf:AnimationSettings x:Key="Contract"
                          Kind="ScaleXFrom,ScaleYFrom"
                          ScaleX="{StaticResource LargeScaleFactor}"
                          ScaleY="{StaticResource LargeScaleFactor}" />
    .
    .
    .
    </ResourceDictionary>

To setup this set of pre-configured AnimationSettings already available in your app, perform the following steps:

  1. Right-click on your project, then click Add > New Item...
  2. Choose Resource Dictionary and name it Animations.xaml
  3. In your App.xaml, add the following:
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Animations.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
  1. In Animations.xaml, copy & paste the contents from the corresponding links below:

Your app now has a global set of common animations ready to use.

Default Animations (WPF Only)

Alternatively to creating your own ResourceDictionary containing your custom AnimationSettings, XamlFlair provides some Default Animations.

To reference these Default Animations in your application, perform the following steps in your App.xaml:

  1. Define the XamlFlair.WPF namespace at the top:
    xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
  1. Update your Application Resources:
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <xf:XamlFlairResources />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

Your application now has a global set of Default animations ready to use.

If Visual Studio Intellisense does not work when using <xf:XamlFlairResources />, you may want to try the following instead:

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/XamlFlair.WPF;component/DefaultAnimations.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

TransformOn Property (WPF Only)

Using the TransformOn property, you can target which type of RenderTransform to apply to your animation. Available options are Render and Layout. When nothing is specified, the default vale is Render. Here's an example of the two:

TransformOn animation

Note: Very important to note that WPF's LayoutTransform does not support any TranslateTransform, therefore translate animations will never work. You can read more about it in the Remarks section here.

Perspective Rotations (UWP Only)

It is important to note that to apply a perspective rotation (also referred to as Swivel) to a target element, it is required that it be wrapped in a container with the layout properties applied to the container element. Therefore, consider the following simple perspective rotation:

<xf:AnimationSettings x:Key="PerspectiveVerticalRotation"
                      Kind="SwivelYFrom"
                      SwivelY="-45" />

Instead of animating the element as such:

<Rectangle Fill="RoyalBlue"
           Width="200"
           Height="200"
           HorizontalAlignment="Center"
           VerticalAlignment="Center"
           xf:Animations.Primary="{StaticResource PerspectiveVerticalRotation}" />

The element should be placed in a container for the animation to work correctly:

<Border Width="200"
        Height="200"
        HorizontalAlignment="Center"
        VerticalAlignment="Center">
    <Rectangle Fill="RoyalBlue"
           xf:Animations.Primary="{StaticResource PerspectiveVerticalRotation}" />
</Border>

Combining Animations

Animations can be combined, and as previously mentioned, any of these combined animations that are commonly used should be placed in the global ResourceDictionary (ex: Animations.xaml):

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:xf="using:XamlFlair">
    .
    .
    .
    <xf:AnimationSettings x:Key="FadeInAndSlideFromLeft"
                          Kind="FadeFrom,TranslateXFrom"
                          Opacity="0"
                          OffsetX="{StaticResource NegativeOffset}" />

    <xf:AnimationSettings x:Key="FadeInAndSlideFromTop"
                          Kind="FadeFrom,TranslateYFrom"
                          Opacity="0"
                          OffsetY="{StaticResource NegativeOffset}" />

    <xf:AnimationSettings x:Key="FadeInAndGrow"
                          Kind="FadeFrom,ScaleXFrom,ScaleXFrom"
                          Opacity="0"
                          ScaleX="{StaticResource SmallScaleFactor}"
                          ScaleY="{StaticResource SmallScaleFactor}" />

    <xf:AnimationSettings x:Key="FadeInAndGrowHorizontally"
                          Kind="FadeFrom,ScaleXFrom"
                          Opacity="0"
                          ScaleX="{StaticResource SmallScaleFactor}" />
    .
    .
    .
    </ResourceDictionary>

This demonstrates a combined animation of a FadeFrom and TranslateFrom:

Fade and translation animation

This demonstrates a combined animation of a FadeFrom, TranslateFrom, and ScaleFrom:

Fade, translation, and scale snimation

Overriding Values

Animations can have their settings overridden directly on the FrameworkElement. This is commonly done to alter values for Delay and Duration so that we don't over-populate the Animations.xaml file with repeated resources. To achieve overriding, use the Animate markup extension paired with the BasedOn property:

<Border xf:Animations.Primary="{xf:Animate BasedOn={StaticResource ScaleFromBottom}, Delay=500}" />

Relative Translations on X and Y Axes

Since hard-coded values for OffsetX and OffsetY can be limiting (such as in cases when dealing with resizable windows), both OffsetX and OffsetY support star-based values:

<Border xf:Animations.Primary="{xf:Animate BasedOn={StaticResource SlideFromLeft}, OffsetX=1.5*}" />

A star-based value will calculate the offset based on the current ActualWidth and/or ActualHeight value(s) of the FrameworkElement, therefore it's important that the element has executed its Loaded event. If ActualWidth and/or ActualHeight are not yet calculated, the offset value will try to be based on Width and/or Height.

Compound Animations

A compound animation is simply a multi-step animation using the CompoundSettings class. Each inner animation executes once the previous one completes, hence they're sequential animations:

Compound animation

<xf:CompoundSettings x:Key="Compound">
    <xf:CompoundSettings.Sequence>
        <xf:AnimationSettings Kind="ScaleXTo"
                              ScaleX="1.25"
                              Duration="1250" />
        <xf:AnimationSettings Kind="ScaleXTo"
                              ScaleX="1"
                              Duration="1250" />
        <xf:AnimationSettings Kind="RotateTo"
                              Rotation="360"
                              Duration="1250" />
    </xf:CompoundSettings.Sequence>
</xf:CompoundSettings>

Note: CompoundSettings support the Event property, which is discussed in a later section.

Repeating Animations

An animation can be repeated by using the IterationBehavior and IterationCount properties (default values of Count and 1 respectively).

Compound animation

The following demonstrates how to run an animation only 5 times:

<Border xf:Animations.Primary="{StaticResource FadeIn}"
        xf:Animations.IterationCount="5" />

The following demonstrates how to run an animation indefinitely:

<Border xf:Animations.Primary="{StaticResource FadeIn}"
        xf:Animations.IterationBehavior="Forever" />

Also note that it is also possible to repeat a Compound animation. For example, using the compound animation (named Progress) from the previous section:

<Border xf:Animations.Primary="{StaticResource Progress}"
        xf:Animations.IterationCount="5" />

Warning: When using repeating animations, you cannot set a Secondary animation on the element.

It's important to note that all XamlFlair animations are "kick-off" animations, in other words, they start and only stop when they complete (or when the associated element unloads), except repeating animations. A repeating animation can be stopped when supplying a false value to the PrimaryBinding property (bindings are covered in the next section):

<CheckBox x:Name="SampleCheckBox"
          IsChecked="False" />

<Rectangle xf:Animations.PrimaryBinding="{Binding IsChecked, ElementName=SampleCheckBox}"
           xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=None}" />

When a false is set on the binding, the animation's current iteration will run until it finishes and then the repeating animation will stop.

Events

By default, all animations execute when the animated element fires its Loaded event. This behavior can be overridden by setting the Event property. Event can be any event that is exposed from the element being animated. For example, to execute an animation on a button when it is clicked, the Click event can be used:

<Button xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=Click}" />

Some examples of common events that can be used:

  • Loaded (default value)
  • Visibility (triggers only when Visibility == Visible)
  • DataContextChanged (triggers when the value is not null)
  • PointerOver
  • PointerExit
  • GotFocus
  • LostFocus

There are some special cases to take note of. The first special case is the DataContextChanged event. When using the DataContextChanged event, it will fire when the DataContext value changes, except for cases where a null value is set, null is filtered out and would not trigger an animation.

Another special case is Visibility. Although no event VisibilityChanged exists on a FrameworkElement, the Visibility property has been treated like an event when the value changes since it can be useful to animate an element when it becomes visible on the UI. If an animation is triggered with Event=Visibility, it will only be triggered whenever a value of Visibile is set.

Bindings

One of the most important values for Event is None, which is a value used to cancel any event-based animation trigger. When specifying None, you will need to manually trigger your animations using the PrimaryBinding or SecondaryBinding properties. These properties are of type bool and expect a value of True in order to execute the corresponding animation. The following is an example of triggering an animation based off the IsChecked of the CheckBox control:

<CheckBox x:Name="SampleCheckBox"
          IsChecked="False" />

<Rectangle xf:Animations.PrimaryBinding="{Binding IsChecked, ElementName=SampleCheckBox}"
           xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=None}" />

The above animation will only execute when the IsChecked is True. If None was not specified for Event, the animation would then execute on Loaded and on the binding.

When working with both PrimaryBinding and SecondaryBinding together (based on the same boolean value), it may be cleaner and simpler to use CombinedBinding. CombinedBinding simply acts as both PrimaryBinding and SecondaryBinding together. Instead of the following:

<CheckBox x:Name="SampleCheckBox"
          IsChecked="False" />

<Rectangle xf:Animations.PrimaryBinding="{Binding IsChecked, ElementName=SampleCheckBox}"
           xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=None}"
           xf:Animations.SecondaryBinding="{Binding IsChecked, ElementName=SampleCheckBox, Converter={StaticResource InverseBoolConverter}}"
           xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None}"
           xf:Animations.StartWith="{StaticResource FadeOut}" />

You would use it as such:

<CheckBox x:Name="SampleCheckBox"
          IsChecked="False" />

<Rectangle xf:Animations.CombinedBinding="{Binding IsChecked, ElementName=SampleCheckBox}"
           xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=None}"
           xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None}"
           xf:Animations.StartWith="{StaticResource FadeOut}" />

By using CombinedBinding in this way, it saves on having to use a converter for the inverse boolean value, which is handled internally.

Primary and Secondary Completion Commands

There may be scenarios where you may want to execute an ICommand when an animation completes. In such a case, two properties exist: PrimaryCompletionCommand and SecondaryCompletionCommand.

In the following example, the command named MyCustomCommand will execute once the primary animation completes:

<TextBlock Text="Example of a completion command"
           xf:Animations.Primary="{StaticResource FadeInAndSlideFromBottom}"
           xf:Animations.PrimaryCompletionCommand="{x:Bind MyCustomCommand}" />

Using the StartWith Property

There will be cases when you will need your UI element to start in a specific state, for example, the element needs to be shrunk before its animation executes. This is achieved using the StartWith property:

<Rectangle xf:Animations.Primary="{xf:Animate BasedOn={StaticResource ScaleFromBottom}, Delay=500}"
           xf:Animations.StartWith="{StaticResource ScaleFromBottom}" />

In the above example, since the element is scaling from the bottom, but with a delay, we need to start in the scaled position, so we use the StartWith property to set its initial state. What StartWith essentially does is setup the initial values on the element as soon as it has loaded.

Using the AllowOpacityReset Property (WPF Only)

The .Net documentation states the following:

In some cases, it might appear that you can't change the value of a property after it has been animated. ...you must stop the animation from influencing the property.

There may be cases when you animate the opacity, in which the opacity animation suddenly resets it's value instead of animating, or doesn't behave as you intend. In cases, you may need to set AllowOpacityReset = False (the default value of AllowOpacityReset is True) to achieve the intended behavior:

<Image xf:Animations.Primary="{StaticResource FadeInThenFadeOut}"
       xf:Animations.AllowOpacityReset="False"
       Source="/Assets/..." />

Using the ClipToBounds Property (UWP And Uno Only)

A helpful property that exists in WPF, ClipToBounds is a helpful property that exists in WPF, but unfortunately not in UWP. Therefore, it has been added in XamlFlair due to its ease of use and handiness. To clip child content to the bounds of the containing element, simply set ClipToBounds to True on the containing element:

<Border xf:Layout.ClipToBounds="True">
.
.
.
<Border>

Debugging Animations

In order to debug an animation and step into the code, use the EnableDebugging property. Debugging is possible due to the inclusion of the SourceLink library. Please be sure to do the following:

SourceLink1 SourceLink2

<Rectangle xf:Animations.EnableDebugging="InitializeElement"
           xf:Animations.Primary="{StaticResource SlideFromLeft}" />

The following tables explains the enumeration values:

Enum Value Description
None Default value. No debugging will occur.
InitializeElement Breaks the debugger in the InitializeElement function of XamlFlair.
RunAnimation Breaks the debugger in the RunAnimation function of XamlFlair.

Logging Animations

The XamlFlair library abstracts its logging using Microsoft.Extensions.Logging.Abstractions. Below is a logging example using Serilog in a UWP app:

public App()
{
    this.InitializeComponent();
    .
    .
    .
    // Setup the Serilog logger
    Log.Logger = new LoggerConfiguration()
        .MinimumLevel.Debug()
        .WriteTo.Debug()
        .CreateLogger();

    // Initalie the XamlFlair loggers using the LoggerFactory (with Serilog support)
	XamlFlair.Animations.InitializeLoggers(new LoggerFactory().AddSerilog());
}

To output the values of one or more animations, simply set Debug to the EnableLogging property on the target FrameworkElement:

<Rectangle xf:Animations.EnableLogging="Debug"
           xf:Animations.Primary="{StaticResource SlideFromLeft}" />

Doing so will provide you with the following similar console output (differs slightly for WPF):

Element = Windows.UI.Xaml.Controls.Button
Kind = FadeFrom, TranslateFrom
TargetProperty = Translation
Duration = 500
Delay = 0
Opacity = 0
OffsetX = 0
OffsetY = 50
OffsetZ = 0
ScaleX = 1
ScaleY = 1
ScaleZ = 1
Rotation = 0
Blur = 0
TransformCenterPoint = 0.5,0.5
Easing = Cubic
EasingMode = EaseOut

As each storyboard executes, it's kept in an internal list until it completes (or gets stopped). To output this internal list, temporarily add the following in your app startup code:

Animations.EnableActiveTimelinesLogging = LogLevel.Debug;

Doing so will provide you with the following similar console output:

---------- ALL ACTIVE TIMELINES --------
Active timeline removed at 12:42:26:43222

Element = Button,  Key = d69f826a-1978-4a4e-b516-4a6b0469238b,  ElementGuid = 195d8c13-1dd7-4fef-a7f3-fc78bdab1cd7
    State = Running,  IsSequence = False,  IsIterating = False,  IterationBehavior = Count,  IterationCount = 0
------------------------------------

---------- ACTIVE TIMELINE --------
Guid d69f826a-1978-4a4e-b516-4a6b0469238b - Updated state to: Completed at 12:42:26:88616
------------------------------------

---------- ALL ACTIVE TIMELINES --------
Active timeline removed at 12:42:26:89614

NO ACTIVE TIMELINES!
------------------------------------

Currently, all the logging in XamlFlair mentioned above is logged at LogLevel.Debug

ListViewBase (UWP and Uno) and ListBox-based (WPF) Animations

ListView item animations

In order to properly implement item animations on list items, it was not enough to simply create attached properties against the ListViewBase (UWP) and ListBox (WPF) controls. Instead, inherited controls were created: AnimatedListView and AnimatedGridView for UWP, and AnimatedListView and AnimatedListBox for WPF, all available from the XamlFlair.Controls namespace:

UWP and Uno namespace:

xmlns:xfc="using:XamlFlair.Controls"

WPF namespace:

xmlns:xfc="clr-namespace:XamlFlair.Controls;assembly=XamlFlair.WPF"

Animating items in lists is slightly different than animating a typical UI element. The main reason for this difference is that the Event value on the corresponding AnimationSettings cannot be changed from its default value. Therefore the following is invalid:

<xfc:AnimatedListView ItemsSource="Binding SampleDataList"
                      xf:Animations:Items="{xf:Animate BasedOn={StaticResource FadeIn}, Event=Visibility}" />

List item animations, by default, animate based on the Loaded event of each visible item, and also based on an update to the ItemsSource property of the list control. In order to disable these default behaviors, the following two properties can be used independently:

<xfc:AnimatedListView ItemsSource="Binding SampleDataList"
                      xf:Animations.AnimateOnLoad="False"
                      ... />

<xfc:AnimatedListView ItemsSource="Binding SampleDataList"
                      xf:Animations.AnimateOnItemsSourceChange="False"
                      ... />

By default, item animations have a delay of 25 milliseconds between each item. This value can be changed using the InterElementDelay property:

<xfc:AnimatedListView ItemsSource="Binding SampleDataList"
                      xf:Animations.InterElementDelay="50"
                      ... />

Just like PrimaryBinding and SecondaryBinding, item animations can be triggered by a binding with the use of the ItemsBinding property:

<xfc:AnimatedListView ItemsSource="Binding SampleDataList"
                      xf:Animations.AnimateOnLoad="False"
                      xf:Animations.ItemsBinding="{Binding MyViewModelProperty}"
                      xf:Animations:Items="{xf:Animate BasedOn={StaticResource FadeIn}}" />

Warning (UWP only): Be aware that if you have any ItemContainerTransitions set on the AnimatedListView or AnimatedGridView, they will be cleared. This is done to avoid conflicting item animations.

Note (Uno only): To avoid any flickers on item animations, there is currently a constraint in place: Items animation must contain a FadeFrom.

xamlflair's People

Contributors

assassin316 avatar luisllamasbinaburo avatar tibel avatar xamlflair avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xamlflair's Issues

Add structured logging

Add structured logging for consumers that support it though libraries such as Serilog

Add support for relative Offsets

Adding support for a relative-offset value allows Translations to not rely on hard-coded values. Relative values will be star-based values as done with Grids (, 0.5, 2*), which will be used calculate based off of ActualWidth or ActualHeight of an element;

Combined Binding doesn't work

I tried to use Combined Binding in examples but when i ran code it dosent work at all.Only primary animation appear secondary not
My code
code.txt

So after check and uncheck my check box even first animation not work.Sorry for bad english.

FadeIn FadeOut combined not work as expected

The FadeOut seems no animation effect, it disappeared immediately.

FadeoutDemo.zip

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
  <TextBlock Text="Hello World" 
             xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=None, Duration=3000}"
             xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None, Duration=3000}"
             xf:Animations.CombinedBinding="{Binding ElementName=ShowText, Path=IsChecked}"
             xf:Animations.StartWith="{StaticResource FadeOut}" />
  <Separator Visibility="Hidden" Height="10" />
  <CheckBox x:Name="ShowText" />
</StackPanel>

NHccLWkbDx

Compound animations not working as intended? (WPF)

Hello,

I have encountered an issue with the compound settings animations in my WPF application. Maybe I am just doing something wrong. I have created two compound animations, each with its individual key:

<xf:CompoundSettings x:Key="Spin">
    <xf:CompoundSettings.Sequence>
      <xf:AnimationSettings Kind="RotateTo"
                            Rotation="360"
                            Easing="Linear"
                            Duration="1250" />
      <xf:AnimationSettings Kind="RotateFrom"
                            Rotation="0"
                            Duration="1" />
    </xf:CompoundSettings.Sequence>
  </xf:CompoundSettings>

  <xf:CompoundSettings x:Key="Pulse">
    <xf:CompoundSettings.Sequence>
      <xf:AnimationSettings Kind="FadeTo"
                            Opacity="0"
                            Duration="800" />
      <xf:AnimationSettings Kind="FadeTo"
                            Opacity="1"
                            Duration="800" />
      <xf:AnimationSettings Kind="TranslateYTo"
                            OffsetY="20"
                            Duration="300" />
      <xf:AnimationSettings Kind="TranslateYTo"
                            OffsetY="0"
                            Duration="300" />
    </xf:CompoundSettings.Sequence>
  </xf:CompoundSettings>

But when I use the keys on two different image controls, it seems that the animations "Spin" and "Pulse" are combined together once the second image is loaded. Here is a short GIF to show this behaviour (the blue cloud image should not rotate!)

compound_animation

Each image control is situated on a different UserControl, the switch between the UserControl is handled by a ContentControl.
I would appreciate some help with this.

Thank you!

Is it possible to add a `DiscreteObjectKeyFrame` into `CompoundSettings.Sequence`?

What I want to do?

  • Set Visibility to Visible before FadeIn.
  • Set Visibility to Collapsed after FadeOut.

In vanilla way, it looks like this:

<Style TargetType="hc:SimplePanel">
  <Setter Property="Visibility" Value="Collapsed" d:Value="Visible" />
  <Style.Triggers>
    <DataTrigger Binding="{Binding IsLoading}" Value="True">
      <DataTrigger.EnterActions>
        <BeginStoryboard>
          <Storyboard>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
              <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
            </ObjectAnimationUsingKeyFrames>
            <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5" />
          </Storyboard>
        </BeginStoryboard>
      </DataTrigger.EnterActions>
      <DataTrigger.ExitActions>
        <BeginStoryboard>
          <Storyboard>
            <DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:0.5" />
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility">
              <DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Collapsed}" />
            </ObjectAnimationUsingKeyFrames>
          </Storyboard>
        </BeginStoryboard>
      </DataTrigger.ExitActions>
    </DataTrigger>
  </Style.Triggers>
</Style>

Effect:

JHzRKVnyza

AnimatedListBox / ListView only animating first element

I'm working on a project combining MahApps.Metro, ReactiveUI and XamlFlair.

I've got an AnimatedListBox as so:

<xfc:AnimatedListBox x:Name="pendingStacksListView"
                                 BorderBrush="Transparent"
                                 BorderThickness="0"
                                 Background="Transparent"
                                 xf:Animations.Items="{xf:Animate BasedOn={StaticResource FadeInAndSlideFromBottom}}"
                >
                
</xfc:AnimatedListBox>

The code behind is simple, and is just binding a ReadOnlyObservableCollection<TViewModel> to the ItemsSource, as per:

public PendingStacksPanelView()
        {
            InitializeComponent();

            this.WhenActivated(disposables =>
            {
                this.OneWayBind(ViewModel, vm => vm.PendingStacks, v => v.pendingStacksListView.ItemsSource)
                    .DisposeWith(disposables);

                this.BindCommand(ViewModel, vm => vm.CreateTestStackCommand, v => v.testStackBtn)
                    .DisposeWith(disposables);
            });
        }

I added a Loaded event handler to the view getting rendered into the list, and can confirm that every instance fires their Loaded event when added to the listbox.

However, only the first item to be added to the listbox ever gets animated, the other items just appear immediately.

Not sure if this is expected behaviour or if there's something I'm missing.

I've also confirmed that the ItemsSource is only getting bound and updated once in the view.

Offset must be a double or a star-based value (ex: 150 or 0.75*).

Hello, I used XamlFlair in my product, my customer send me a error report (seems was Czech language environment). But I can't reproduce on my machine (Chinese language environment).

image

The exception from:

throw new ArgumentException($"{nameof(Offset)} must be a double or a star-based value (ex: 150 or 0.75*).");

I read the source code, it seems skip the second if condition, it's very strange.

else if (offsetValue.EndsWith("*") && double.TryParse(offsetValue.TrimEnd('*'), out var result))
{
return new Offset()
{
OffsetFactor = result
};
}

And these are all my codes which reference OffsetY=-0.75*.

image

Version: XamlFlair.WPF 1.2.8
OS: Win 10.0.19042.0
.NET: 5.0.8

Any suggestions?

IterationBehavior="Forever" doesn't seem to work

I defined an animation in UWP:

<xf:AnimationSettings x:Key="TestRotate" Easing="Cubic" EasingMode="EaseInOut" Kind="RotateTo" Rotation="360" Duration="2000" />

Then I tried using it in a control:

<CheckBox x:Name="SampleCheckBox"
                                  Margin="0,0,8,0"
                                  IsChecked="False" />

                        <Viewbox x:Name="kFlake"
                                 Width="20"
                                 Height="20"
                                 xf:Animations.IterationBehavior="Forever"
                                 xf:Animations.Primary="{xf:Animate BasedOn={StaticResource TestRotate},
                                                                    Event=None}"
                                 xf:Animations.PrimaryBinding="{Binding IsChecked, ElementName=SampleCheckBox}">
                            <Border Width="50"
                                    Height="50"
                                    BorderBrush="White"
                                    BorderThickness="1" />
</Viewbox>

There's a couple issues:

  1. It only animates once, doesn't repeat forever.
  2. Uncheck the checkbox doesn't stop the animation.
  3. Recheck the checkbox doesn't start the animation again.

I'm trying to use this for a busy indicator so I'd like to bind to a viewmodel prop when the app is busy. Do I need to do this another way?

[Feature request ] Use ColorTo animation on border in WPF

XamlFlair.WPF 1.2.8

WPF XAML:

<Window.Resources>
    <xamlFlair:AnimationSettings
        x:Key="SampleColorAnimation"
        ColorOn="Background"
        Delay="2000"
        Kind="ColorTo"
        Color="DarkGreen"
        Duration="5000" />
</Window.Resources>

<Border
    Width="100"
    Height="100"
    xamlFlair:Animations.Primary="{xamlFlair:Animate BasedOn={StaticResource ScaleFromLeft},
                                                     Duration=5000,
                                                     Delay=2000}"
    xamlFlair:Animations.Secondary="{StaticResource SampleColorAnimation}"
    Background="Brown" />

Expected behavior:
Border's color animation can be executed normally

Actual behavior:
it throw an exception :
System.ArgumentException:“$Cannot animate the ColorAnimation. Make sure the animation is applied on a Control, TextBlock, or Shape. Also make sure that an existing brush exists on the corresponding property (Background, Foreground, BorderBrush, Fill, or Stroke).”

Not working with Uno >=3.10

I have a project that uses XamlFlair.Uno. If I update that one to Uno.UI 3.10. it fails on build with NameScope-Errors if I have DataTemplate in use.

Steps to resolve:
Create a new Uno-project and replace the "Hello-World"-Textbox in the Mainpage with this one:

<TextBox Text="Test-Textbox"
                         Header="Name" Height="68"
                         Margin="20" BorderThickness="0" CornerRadius="6">
            <TextBox.HeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}" FontSize="20"/>
                </DataTemplate>
            </TextBox.HeaderTemplate>
        </TextBox>

This would work (run the application). But if you now add XamlFlair.Uno 1.2.10 it failes with an build-error like this:
"UnoTestNameScope\UnoTestNameScope.Droid\obj\Debug\100\g\XamlCodeGenerator\MainPage_a1d9d1bb2ca9de3384922e19add4f444.g.cs(143,16,143,21): error CS1061: "NameScope" enthält keine Definition für "Owner", und es konnte keine zugängliche Owner-Erweiterungsmethode gefunden werden, die ein erstes Argument vom Typ "NameScope" akzeptiert (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis)."

(Missing "Owner" on "NameScope"). I assume this is due to the fact that XamlFlair.Uno uses an older reference of Uno (3.5) and they collide in any way - though I do not know the exact reason.

Problem installing Nuget Package - XamlFlair.WPF

Hi,

May I ask if XamlFlair.WPF works with WPF apps targetting .Net Framework 4.6.1?

I am facing issues installing XamlFlair.WPF nuget package where it fails with the following error message:

Install failed. Rolling back...
Package 'XamlFlair.WPF.1.2.5 : Microsoft.Extensions.Logging.Abstractions [1.1.1, ), Microsoft.SourceLink.GitHub [1.0.0, ), System.Reactive [5.0.0, )' does not exist in project.

After the failure, I get this error message:

Error Could not install package 'XamlFlair.WPF 1.2.5'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I would really love to integrate this awesome library into my project but failing to do so at the moment. Would you know what this would be happening?

Upgrade to support Uno 2.4.4

Currently an error occurs if a project upgrades to Uno 2.4.4

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(842,3): error MT2101: Can't resolve the reference 'Windows.UI.Xaml.DependencyProperty Windows.UI.Xaml.Media.GradientBrush::get_GradientStopsProperty()', referenced from the method 'System.Object UnoApp.MetadataBuilder_585::GetGradientStops(System.Object,System.Nullable`1<Windows.UI.Xaml.DependencyPropertyValuePrecedences>)' in 'Uno.UI, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'

WPF StartWith Problem

I tested below code in WPF.

<Rectangle xf:Animations.Primary="{xf:Animate BasedOn={StaticResource ScaleFromBottom}, Delay=5000, Event=Visibility}"
           xf:Animations.StartWith="{StaticResource ScaleFromBottom}" />

Then I added 2 buttons,
one (Hide) to make the element Visibility == Collapsed,
and the other button (Show) to make the element Visibility == Visible.

The element is initially Collapsed in the XAML.
When I clicked "Show" Button, it works perfectly.
Then, I clicked "Hide" Button. It is collapsed as expected.

But, after I clicked the "Show" for the 2nd time.
The element is visible directly, and only after the Delay, the animation is start working ?

Am I missing something ?

XamlFlair.WPF 1.2.13 not animating Fadeout

I copied the code from the Readme.md part that talks about CombinedBinding like so:

<Rectangle
               xf:Animations.CombinedBinding="{Binding ElementName=mainWindow, Path=DataContext.IsVisible}"
           xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeIn}, Event=None, Duration=1500}"
           xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None, Duration=1500}"
           xf:Animations.StartWith="{StaticResource FadeOut}"
                Fill="Red"
            ></Rectangle>

When my IsVisible turns true then, indeed, i see FadeIn.
When it turns false, the rectangle is immediately invisible with no animation.

I am on WPF .Net 6, VS 2022, Win 10 21H1 (19043.1526).

How can I get documentation?

It seems good, but I still don't know how to use XamlFlair. Is there some readable documentation for XamlFlair?

Support for Layout transformation

Hello,

Animations currently use RenderTransformation, that is faster than Layout transformation and allow more animations, but doesn't change the other elements in the UI

I agree that this should be the normal behavior, but I found interesting to allow user to change to Layout transformation.

For example,
Using render transformation
render-slide

Using layout transformation
transform-slide

I have been testing in a simple way to allow user to change transformation. I have created a new DependendyProperty TransformProperty in AnimationSettings, with two options: Render (default) and Layout

Then, it could be use in your app that way

<Border xf:Animations.Primary="{xf:Animate BasedOn={StaticResource ScaleFromLeft}, Transform=Layout}">

What do you think?

Problem installing nuget package for WPF

When installing the nuget package for WPF I get the following errors:

packages\Microsoft.Build.Tasks.Git.1.0.0\build\Microsoft.Build.Tasks.Git.targets(24,5): warning : Unable to locate repository with working directory that contains directory ;

packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets(52,5): warning : Source control information is not available - the generated source link is empty;

I researched extensively and tried all the fixes I could find, but no luck. I'm I doing something wrong or is there an issue with your nuget package?

Thanks.

PointerOver on Border

I have been using XamlFlair to animate a Border. After updating to anything after 1.2.9 I get an error saying "Could not find event 'PointerOver' on object of type 'System.Windows.Controls.Border'.".

All my code looks fine and works fine on older versions of XamlFlair. I added the code below to the XamlFlairDemo and it crashes with the same error.

Any thoughts?

               <Border Width="100"
                        Height="100"
                        Background="Aqua"
                        xf:Animations.Primary="{xf:Animate BasedOn={StaticResource Shrink}, Event=PointerOver, Duration=300}"
                        xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource Grow}, Event=PointerExit, Duration=300}">
                    <TextBlock Text="Hello"  HorizontalAlignment="Center"  VerticalAlignment="Center" />
                </Border>

Can I export animation as a video or as a series of image files?

Hello:
I found this repo, it seems to be interesting. But I want to know if I can export some of the animaitons either as a video (MP4 format) for as a series of image files (PNG format).
I know I can use 3rd party screen recorder to do the job, but I want to see if I can have some built-in feature for this.
Thanks,

AnimatedListView Compound Animations?

Hi,

I'm trying to have an animation on a ListView when the ItemsSource changes, which moves the items off the screen one way, then the new items back onto the screen the other way, but when I try to set my:

  <xfc:AnimatedListView 
                xf:Animations.AnimateOnLoad="True"
                xf:Animations.AnimateOnItemsSourceChange="True"
                xf:Animations.Items="{xf:Animate BasedOn={StaticResource Compound}}">

</xfc:AnimatedListView>

I get the following error:

XamlFlair.CompoundSettings is not a valid value for property 'Items'.

I can't find any documentation about Compound Settings explicitly not being supported by AnimatedListView, are they not?

CompoundSettings not working

Hi

Im trying out XamlFlair and think I found a problem with compound animation that should repeat forever. Here is my xaml code

<Image
  Height="100"
  Margin="20,8,60,8"
  xf:Animations.Primary="{StaticResource TestCompound}"
  xf:Animations.IterationBehavior="Forever"
  Source="/Assets/Logo.png" />
<xf:CompoundSettings x:Key="TestCompound">
  <xf:CompoundSettings.Sequence>

    <!--  show / fade in  -->
    <xf:AnimationSettings Delay="1000" Kind="FadeFrom" Opacity="0" Duration="2000" />

    <!-- rotate -->
    <xf:AnimationSettings Kind="RotateTo" Rotation="360" Duration="2000" />

    <!--  hide / fade out  -->
    <xf:AnimationSettings Delay="10000" Kind="FadeTo" Opacity="0" />

  </xf:CompoundSettings.Sequence>
</xf:CompoundSettings>

The first run seems to work perfect. The logo fades in (becomes visible), then rotated, and finally fade out (gets hidden) again. Then it starts all over but now I will never see the rotate animation anymore.

The animation is only played for the first time

I have a Border and I control its Visibility property (toggle Visible/Collapsed) via shortcut keys.
I need the animation to play when I switch Visibility states(the initial value is Collapsed).
I found the animation(Primary: FadeInAndSlideFromTop) is only played for the first time(Collapsed -> Visible).

<Border x:Name="myBorder"
        xf:Animations.CombinedBinding="{Binding Visibility, ElementName=myBorder, Converter={StaticResource VisibilityToBoolConverter}}"
        xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndSlideFromTop},
                                           Duration=200,
                                           Event=None}"
        xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOutAndSlideToTop},
                                             Duration=200,
                                             Event=None}"
        Visibility="Collapsed"> 
</Border>

Is XamlFlair only suitable for entrance and exit animations? Is it difficult to express animations that need to be triggered by repeated switching in different states?

DefaultAnimations in UWP

Hi,

Is is posible to have the same DefaultAnimations in UWP than WPF, using this as UWP resource URL

<!-- UWP -->
<ResourceDictionary Source="ms-appx:///XamlFlair.UWP/DefaultAnimations.xaml" />

I included this in a previous commit, but I think you didn't see it, and at some point some code mixed and overwrite that.
(in fact, now the readme is not correct, it mix WPF and UWP path)

Using XamlFlair in a WiX setup wizard

I'm using WixSharp to build an installer using its WPF capability. I tried to use XamlFlair in one of the dialogs but the animations don't run. I got everything working in a WPF test app, so I know I have it set up correctly. Is there an event that doesn't fire perhaps?

pay

Can I scan the code to pay? For example, WeChat, Alipay

WPF - Handles count keep increasing

WPF XamlFlair
1000x page navigation using automation tool

I notice using xamlflair the handles keeps increasing, something is not disposed or released.
When reaches 10,000 handles, the app freezes and closes

The yellow line represent handles
The blue represent memory usage

image

After excluding xaml flair, the handles is stable and doesnt crash after 1 week running

image

RenderTransformOrigin does not exist in the namespace

Hi, great work ! 👍

I get a strange error though. It appears after adding the nuget package for WPF and the Animations.xaml resource dictionary described in your docs:

The property 'RenderTransformOrigin' does not exist in XML namespace 'clr-namespace:XamlFlair;assembly=XamlFlair.WPF'.
error

But it could be just some other problem on my side...

[Suggestion] Make easier to import DefaultAnimations.xaml

Like HandyControls, it's very easy to import resources.

image

Make a class inherits ResourceDictionary that default Source is pack://application:,,,/XamlFlair.WPF;component/DefaultAnimations.xaml to make users easier import, rather than:

<ResourceDictionary Source="pack://application:,,,/XamlFlair.WPF;component/DefaultAnimations.xaml"/>

WPF Question: Is it possible to start an XAML-FLair Animation from C# Code ?

Hi, I´d like to know if it would also be possible to start an XAML-Flair Animation within C# Code ?

I´d like to have Visibility Animation, when Visibilty is set to "Collapsed" or "Hidden".
Maybe there is also a better way, but I have been thinking about implementing a VisibilityConverter that plays a FadeOut / Slide animation when Visibility != Visible. Here I would like to use a XAML-Flair animation. Is that possible?

Thank you in advance!

public class VisibilityConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        bool isVisible = (bool)value;
        if (!isVisible)
        {
            // XAML-FLair Animation here
        }
        return isVisible ? Visibility.Visible : Visibility.Collapsed;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Cannot use XamlFlair in Uno-Multi Platform Library

I try to develop a controls-library for Uno Platform, where I want to take advantage of XamlFlair. But if I add The XamlFlair.Uno-Package (v1.2.6) to a Uno Multi Platform Library project, I get the error "Type or Namespace 'ComponentHolder' is not available in the namespace 'Windows.UI.Xaml.Markup'" (exact message may differ, this was translated from my german message).

Do you know what might cause that issue or how to solve it?

Steps to reproduce:

  1. Create an Uno-App from the VS-template
  2. Add a Uno Multi Platform Library
  3. Add XamlFlair.Uno-Nuget
  4. Reference the library from e.g. the UWP-Project
  5. Build => it fails with that error.

Thank you!

When the AnimatedListView is collapsed and expanded again, the ListViewItem state is reset

I have an AnimatedListView and I need item to FadeOut when "SampleData.IsFoo == True" and FadeIn when it goes back to "False".

Let's say that some of the data is now in the FadedOut(Opacity=0.2) state. Then when I drag the GridSplitter to the top, the AnimatedListView is collapsed, then I drag the GridSplitter to the bottom and the faded ListViewItem returns to its normal state (Opacity=1), i.e., I tried the traditional DataTrigger+ Storyboard mode, which reapplies the animation when the AnimatedListView resumes Expanded/Visible.

In other words, XamlFlair should reapply the animation when the element shows disappear and then appears.

P.S: I haven't tested ListView for this issue, I think AnimatedListView should not be different from ListView in this issue.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>

    <xfc:AnimatedListView ItemsSource="{Binding SampleDataList}"
                          xf:Animations.Items="{StaticResource FadeInAndSlideFromTop}">
        <xfc:AnimatedListView.ItemContainerStyle>
            <Style TargetType="{x:Type ListViewItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <Border Background="Blue"
                                xf:Animations.AllowOpacityReset="False"
                                xf:Animations.CombinedBinding="{Binding IsFoo}"
                                xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeOut},
                                   Opacity=0.2,
                                   Duration=1000,
                                   Delay=1000}"
                                xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeIn},
                                     Duration=1000,
                                     Opacity=1}" >
                                 <TextBlock Text="{Binding Bar}" />
                            </Border>
            </Style>
        </xfc:AnimatedListView.ItemContainerStyle>

    <GridSplitter Grid.Row="1"
              Height="2"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Center"
              Background="LightGray" />

    <Border Grid.Row="2" />
</Grid>
public class SampleData
{
    public string Bar { get; set; }
    public string IsFoo { get; set; }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.