如何在 Windows 8/WinRT 中将 SVG 文件转换为 XAML [英] How to convert SVG file to XAML in windows 8 / WinRT

查看:51
本文介绍了如何在 Windows 8/WinRT 中将 SVG 文件转换为 XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在 Windows 8/WinRT 中将 SVG 文件转换为 XAML.我是这个 XAML/SVG 环境的新手.所以任何人都请帮我在windows 8中实现相同的.我需要解析这个svg文件并且需要通过代码在页面中显示内容.

How i can convert SVG file to XAML in windows 8 / WinRT. I am new to this XAML / SVG environment. So anyone please help me to implement the same in windows 8. I need to parse this svg file and need to display the content in the page through code.

推荐答案

对我来说最简单的方法如下:

For me the simplest way to do it is the following:

  1. 在免费的矢量绘图工具Inkscape.svg文件>
  2. 另存为Microsoft XAML (*.xaml)"

此外,您可能需要在转换后稍微更新结果输出文件,因为并非所有 XAML 处理引擎都支持将字符串转换为数字(如对 为什么此 Xaml 路径会导致 Silverlight 崩溃?).所以,例如,如果你有这个:

Also you may need to update the result output file a bit after conversion, since not all XAML processing engines support converting a string to Figures (as described in the accepted answer to Why does this Xaml Path crash silverlight?). So, for example, if you have this:

<Path Fill="#FFEDEDED" StrokeThickness="1" Stroke="#FFA3A3A3" Opacity="0.7" 
                VerticalAlignment="Center" HorizontalAlignment="Center" >
    <Path.Data>
        <PathGeometry Figures="m 1 2 l 4.0525 5.2361 l 4.0527 -5.2361 z "/>
    </Path.Data>
</Path>    

那么你需要把它改成这样:

then you will need to change it to this:

<Path Fill="#FFEDEDED" StrokeThickness="1" Stroke="#FFA3A3A3" Opacity="0.7" 
            VerticalAlignment="Center" HorizontalAlignment="Center"
            Data="m 1 2 l 4.0525 5.2361 l 4.0527 -5.2361 z" />

- 或 -

您可以使用稍微不同的方式从 Inkscape 导出 xamlTim Heuer 在对问题的接受回答中描述了将 SVG 转换为 XAML,因为两种方式产生不同的 xaml 输出:

You could use a bit different way to export the xaml from Inkscape, described by Tim Heuer in accepted answer to the question Convert SVG to XAML, because both ways produce different xaml output:

方法(是的,超级黑客):

Method (yes, superhack):

  • 使用 Inkscape 保存为 PDF

  • Use Inkscape to save as PDF

将文件扩展名从 PDF 重命名为 AI

Rename the Filename extension from PDF to AI

使用 Expression Design 打开 AI 文档

Use Expression Design to open AI document

导出到 Silverlight Canvas

Export to Silverlight Canvas

更新 (2015-08-25)

我发现自己越来越频繁地使用第二种(hack")方式,而不是第一种(更直接),因为它创造了更多可预期"的效果.我称之为 XAML.

I've found my self using the second ("hack") way more and more often rather then first (more straightforward) one, because it creates more "expectable" XAML as I would call it.

这篇关于如何在 Windows 8/WinRT 中将 SVG 文件转换为 XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆