Getting Started with Lottie-Windows
You probably have a JSON file that was exported from Adobe AfterEffects using the BodyMovin plugin. If not, you can find many from the fantastic community of Lottie designers and creators. Let’s bring these animations to your Windows applications with the following steps:
(Optional but Recommended) Install the Lottie Viewer application from the Store and validate that the JSON file — LottieLogo1.json in this example — works as expected. If there are any known issues due to unsupported AfterEffects features, the warning icon may light up and provide more context.
- Go to the Nuget Package Manager by navigating to Project > Manage Nuget Packages.
- Check the Include prerelease box and search for “Microsoft.UI.Xaml” in nuget.org.
- Install the latest prerelease version of the nuget package available.
Modify your Page.xaml to include the namespace:
Install the latest Microsoft.Toolkit.Uwp.UI.Lottie nuget package by following steps similar to those listed above. Modify your Page.xaml to include the namespace:
Add the JSON file to your project:
- Add LottieLogo1.json to the /AnimatedVisuals folder and include by right-clicking > Add > Existing Item.
- Set its Build Action to Content in the Properties window.
<Border> <!--AnimatedVisualPlayer with AutoPlay--> <muxc:AnimatedVisualPlayer x:Name="LottiePlayer"> <!--LottieVisualSource with JSON UriSource--> <lottie:LottieVisualSource x:Name="LottieJsonSource" UriSource="ms-appx:///AnimatedVisuals/LottieLogo1.json"/> </muxc:AnimatedVisualPlayer> </Border>
Since the AutoPlay property is set to True by default, the result will be this looping animation:
Submit and view feedback for