Sumnoon
Sumnoon

Reputation: 135

Lottie Animation in WinUI 3

I am trying to implement lottie animation in a WinUI 3 app. Previously it was implemented in UWP. Where I used AnimatedVisualPlayer from Microsoft.UI.Xaml.Controls and LottieVisualSource from Microsoft.Toolkit.Uwp.UI.Lottie. The code snippet is shown here,

<AnimatedVisualPlayer Stretch="None">
    <LottieVisualPlayer UriSource="AnimatedImage.json" />
</AnimatedVisualPlayer>

But in WinUI3 I cannot find any alternate for AnimatedVisualPlayer. Is there any alternate way to use Lottie Animation in WinUI 3?

Upvotes: 3

Views: 640

Answers (2)

Chassak
Chassak

Reputation: 1

I cant tell with the image you sent but I think you forgot to set "Build Action" as "Content" in the properties window.

https://learn.microsoft.com/en-us/windows/communitytoolkit/animations/lottie-scenarios/getting_started_json

enter image description here

Upvotes: 0

Andrew KeepCoding
Andrew KeepCoding

Reputation: 13203

You should need to install the CommunityToolkit.WinUI.Lottie NuGet package.

<Page
...
    xmlns:lottie="using:CommunityToolkit.WinUI.Lottie">

    <AnimatedVisualPlayer x:Name="LottiePlayer">
        <lottie:LottieVisualSource x:Name="LottieJsonSource" UriSource="ms-appx:///AnimatedVisuals/LottieLogo1.json"/>
    </AnimatedVisualPlayer>

</Page>

Upvotes: 2

Related Questions