如何在WPF / XAML项目中使用Rive动画?

ttcibm8c  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(146)

我有一个*.rive文件,我想在我的WPF应用程序中使用它,就像加载微调器一样。
有任何方式来使用驱动文件在WPF使用图像,媒体元素等。
我需要将其转换为gif格式吗?

q43xntqr

q43xntqr1#

Short answer: You cannot

  • Rive is not just an animation tool, but an animation framework that requires a specially written runtime for different kinds of hosts.
  • Rive's documentation says they only have first-party support for:
  • The web (and a first-party React wrapper).
  • iOS, Android, Flutter, Tizen
  • React Native
  • "C++"
  • Note the lack of WPF, XAML, WinUI, UWP, Jupiter, Silverlight, WinForms, etc.
  • Microsoft's desktop developer story in 2021 sure is fun, isn't it?
  • MS hasn't had a clear and consistent desktop story since Windows 7, it's depressing, and still awful .

I note that "C++" isn't a platform, just a language, so it's odd that they describe it like that. Anyway, their C++ runtime ships with a renderer for Skia , which isn't of much use

Long answer: You can, if you want to put the effort in

  1. Clone and build their C++ runtime.
  • Replace the Skia renderer with a new renderer of your own creation that renders to WPF somehow.
  • You can host Skia within WPF, but it's an opaque surface: the structure and contents of the Rive animation wouldn't be rendered directly by WPF which would introduce inefficiencies.
  • Also, I think WPF is still stuck on DirectX 9, and there might be functionality in Rive that would benefit from being on DX12.
  • And the rest is an exercise for the reader.
vojdkbi0

vojdkbi02#

我还没测试过
下面是C# + UWP https://github.com/rive-app/rive-sharp中驱动器运行时
以下是如何在WPF In WPF control - display a UWP app中显示UWP方法

相关问题