2017-06-29 110 views
0

我有一個svg,我在Inkscape中打開並保存爲xaml。當我看到我看到的xaml時,xaml缺少一些元素。有沒有辦法將這個文件保存到xaml?或者,Inkscape中有沒有一種方法可以修改元素,從而避免錯誤發生?Inkscape不保存正確的xaml

這裏是我的SVG:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="480" width="640" viewBox="0 0 640 480"> 
    <defs> 
    <path id="a" fill="#ffde00" d="M-.588.81L0-1 .588.81-.952-.31H.952z"/> 
    </defs> 
    <path d="M0 0h640v480H0z" fill="#de2910"/> 
    <use xlink:href="#a" transform="matrix(71.9991 0 0 72 119.999 120)" width="30" height="20"/> 
    <use xlink:href="#a" transform="matrix(-12.33562 -20.5871 20.58684 -12.33577 240.291 47.996)" width="30" height="20"/> 
    <use xlink:href="#a" transform="matrix(-3.38573 -23.75998 23.75968 -3.38578 287.95 95.796)" width="30" height="20"/> 
    <use xlink:href="#a" transform="matrix(6.5991 -23.0749 23.0746 6.59919 287.959 168.012)" width="30" height="20"/> 
    <use xlink:href="#a" transform="matrix(14.9991 -18.73557 18.73533 14.99929 239.933 216.054)" width="30" height="20"/> 
</svg> 

這裏所產生的XAML:

<?xml version="1.0" encoding="UTF-8"?> 
<!--This file is NOT compatible with Silverlight--> 
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform"> 
    <Canvas Name="svg17" Width="640" Height="480"> 
    <Canvas.RenderTransform> 
     <TranslateTransform X="0" Y="0"/> 
    </Canvas.RenderTransform> 
    <Canvas.Resources> 
     <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="a" Fill="#FFFFDE00" x:Key="a"> 
     <Path.Data> 
      <PathGeometry Figures="M-.588.81L0-1 .588.81-.952-.31H.952z" FillRule="NonZero"/> 
     </Path.Data> 
     </Path> 
    </Canvas.Resources> 
    <!--Unknown tag: metadata--> 
    <!--Unknown tag: sodipodi:namedview--> 
    <Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path5" Fill="#FFDE2910"> 
     <Path.Data> 
     <PathGeometry Figures="M0 0h640v480H0z" FillRule="NonZero"/> 
     </Path.Data> 
    </Path> 
    </Canvas> 
</Viewbox> 

你可以看到,有5個的XLink:HREF被丟失在輸出中。

+0

xlink:href attribs不會被移植到期望的行爲。 SVG不是XAML。 –

+0

難道你不這樣認爲,在xaml文件中使用資源「a」會很容易。我手邊沒有準確的語法,但我認爲這應該也可以在xaml中使用。 – MTR

+0

這是,但你必須明白,SVG是一個不同的野獸。您仍然可以從Path數據元素([示例])獲取事件等(https://stackoverflow.com/questions/43350165/is-there-any-way-to-make-geometrydrawing-interactive-from-the-ui或者 - 如何對LOA/43355097#43355097)) –

回答

0

對於任何有興趣的人,我在Inkscape中找到了一個解決方法: 只需在所有元素上使用「Unlink Clone」,並且svg中不再有xlinks。