在 Windows 窗体/WPF 中使用 SVG 的库?
是否有任何库
- 允许将 svg 直接绘制到 Windows 窗体应用程序
- 到 WPF 应用程序
我使用 Inkscape,因为我喜欢那个程序。 然后我有了那些令人惊叹的 svgs,必须将它们导出为 png (WinForm) 才能使用它们,或者将它们转换为 xaml 代码 (WPF) (Kaxaml 帮助我)。
有没有办法直接使用我的 svgs?
Are there any libraries which
- Allow to draw svg direct to a Windows Forms application
- to a WPF application
I draw graphics and design everything with Inkscape, because I love that program.
Then I have those stunning svgs and have to either export them to png (WinForm) to use them or convert them to xaml-code (WPF) (Kaxaml helps me).
Is there a way to directly use my svgs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
哇,我只需阅读,Inkscape 支持另存为 XAML。 到目前为止我还没有意识到这一点羞耻。
但这仍然不能解决我的 WinForms 问题......
Wow, I just read that Inkscape supports saving as XAML. I didn't realize that up to now shame.
But that still doesn't solve my problems with WinForms...
我个人很讨厌 Microsoft 的产品/开发工具中没有对 SVG 的原生支持。 我发现了两个相当完整但仍不成熟的 SVG 库,在撰写本文时它们似乎很活跃,但肯定需要贡献者。
IIRC 两个库都输出一个 Drawing 对象,可以通过 Image 类直接使用; 您会发现,它们都非常易于使用。
I personally hate how there's no native support for SVG in Microsoft's products/development tools. I've found two fairly complete but still immature SVG libraries that seem to be active as of this writing, definitely in need of contributors though.
IIRC both libraries output a Drawing object which can be used directly through the Image class; You'll figure it out, they're both pretty straightforward to use.
如果你想将它们直接加载到WPF中,
我从以下位置获得了更好的结果: https://github.com/ElinamLLC/SharpVectors
If you want to load them directly into WPF,
I got better results from: https://github.com/ElinamLLC/SharpVectors
是的,您可以使用 AB4D 中的 ReaderSVG 直接从 XAML 获取 WPF。
关于 WinForms,删除了 Kent Boogart 示例的先前链接,因为它在 2019 年的某个时候被删除。
复制以下内容 此 dotnetways 帖子
要将 WPF 控件或 WPF 用户控件(本例中为 wpfControl)托管到 Windows 窗体应用程序中,请创建 ElementHost 类的实例并添加 WPF 控件/用户控件作为 ElementHost 实例的子级。
现在,将 ElementHost 的实例添加到 Windows 窗体中的容器控件(例如此处的 containerPanel)
Yes, you can use ReaderSVG from AB4D to get WPF directly from XAML.
Regarding WinForms, removed a previous link to Kent Boogart's example as it was deleted sometime in 2019.
Copy below from this dotnetways post
To host a WPF control or WPF user control (wpfControl in this example) into Windows Form application, create an instance of ElementHost Class and add your WPF control/user control as child to the instance of ElementHost.
Now, add the instance of ElementHost to a container control in your windows form (for instance containerPanel here)