Lottie is a tool created by Airbnb to bring quality animations into your native apps. In this article, I will show you how to use it in a Universal Windows Platform project.
Create animations in UWP
Since UWP is a XAML based technology, you can create animations with the provided tools from Blend and Visual Studio.
The basic approach is to use storyboards, like WPF project for animating the UI.

The code for this type of animation looks like,
- <Storyboard x:Name="MoveEllipse"
- AutoReverse="True">
- <DoubleAnimation Duration="0:0:1" To="717" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="ellipse" d:IsOptimized="True"/>
- <DoubleAnimation Duration="0:0:1" To="-415.5" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="ellipse" d:IsOptimized="True"/>
- </Storyboard>
A second approach would be Composition API. Composition API is a Visual layer that sits between the Windows 10 XAML Framework and DirectX. You can draw shapes, images and animate them or apply some cool effects. This solution requires a little more work because the layer is lower level. The code for this type of animation looks like,
- var animation = _compositor.CreateScalarKeyFrameAnimation();
- var easing = _compositor.CreateLinearEasingFunction();
- animation.InsertKeyFrame(0.0f, 0.0f);
- animation.InsertKeyFrame(1.0f, 360.0f, easing);
- animation.Duration = TimeSpan.FromMilliseconds(3000);
- animation.IterationBehavior = AnimationIterationBehavior.Forever;
- _visual.StartAnimation(nameof(_visual.RotationAngleInDegrees), animation);
- _visual.CenterPoint = new Vector3(_visual.Size.X / 2.0f, _visual.Size.Y / 2.0f, 0);
Where the visual is the representation of the control (here the square) in a visual composition element, it can be a XAML control.

These two solutions are working very well to make quality UWP applications but this is not the most convenient way to work with for complex animations if you are not at ease with these principles. This is why I will present Lottie in this article.
Use Lottie to make complex animations very easily
Lottie parses JSON files format to render animation from Adobe After Effects, an effects editor to create animations. This tool was initially available on iOS, Android and React but thanks to Windows developers' community work, Lottie is now available in a NuGet package called LottieUWP.
It supports Windows 10 from November Update (build 10586) and above.
You can make your own animation or you can get some from LottieFiles repository, note that you can bring your contribution to this.

Configure new project
Ok, let’s start now by creating a new UWP project inside Visual Studio. Take care that your application minimum platform version is November Update so that you can use LottieUWP.

I am selecting the Blank app template and giving it a name (LottieAnimation).

First, go to NuGet packages manager and search for LottieUWP with the latest version (if NuGet did not find it, check Include prerelease option to see it).

Integrate an animation



Sagar Pandurang KapPosted Mar 6, 2018, 12:09 AM
Wow thats creazy....