“Lottie Animation in WinUI 3” 可以翻译为 “WinUI 3 中的 Lottie 动画”。

huangapple go评论61阅读模式
英文:

Lottie Animation in WinUI 3

问题

我正在尝试在WinUI 3应用程序中实现Lottie动画。之前它是在UWP中实现的。在UWP中,我使用了Microsoft.UI.Xaml.Controls中的AnimatedVisualPlayerMicrosoft.Toolkit.Uwp.UI.Lottie中的LottieVisualSource。代码片段如下所示:

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

但在WinUI 3中,我找不到AnimatedVisualPlayer的替代方法。是否有任何替代方法来在WinUI 3中使用Lottie动画?

英文:

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,

&lt;AnimatedVisualPlayer Stretch=&quot;None&quot;&gt;
    &lt;LottieVisualPlayer UriSource=&quot;AnimatedImage.json&quot; /&gt;
&lt;/AnimatedVisualPlayer&gt;

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

答案1

得分: 1

你需要安装CommunityToolkit.WinUI.Lottie NuGet包。

&lt;Page
...
    xmlns:lottie=&quot;using:CommunityToolkit.WinUI.Lottie&quot;&gt;

    &lt;AnimatedVisualPlayer x:Name=&quot;LottiePlayer&quot;&gt;
        &lt;lottie:LottieVisualSource x:Name=&quot;LottieJsonSource&quot; UriSource=&quot;ms-appx:///AnimatedVisuals/LottieLogo1.json&quot;/&gt;
    &lt;/AnimatedVisualPlayer&gt;

&lt;/Page&gt;
英文:

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

&lt;Page
...
    xmlns:lottie=&quot;using:CommunityToolkit.WinUI.Lottie&quot;&gt;

    &lt;AnimatedVisualPlayer x:Name=&quot;LottiePlayer&quot;&gt;
        &lt;lottie:LottieVisualSource x:Name=&quot;LottieJsonSource&quot; UriSource=&quot;ms-appx:///AnimatedVisuals/LottieLogo1.json&quot;/&gt;
    &lt;/AnimatedVisualPlayer&gt;

&lt;/Page&gt;

答案2

得分: 0

I can't 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

“Lottie Animation in WinUI 3” 可以翻译为 “WinUI 3 中的 Lottie 动画”。

英文:

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

“Lottie Animation in WinUI 3” 可以翻译为 “WinUI 3 中的 Lottie 动画”。

huangapple
  • 本文由 发表于 2023年6月1日 13:16:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76378841.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定