How to: XAML
-> c# System.Windows.Media.Geometry
?
I want to create vector image (for example, in Inkscape), save it to XAML, than take whole file (from the very first "<" symbol to the very last symbol ">"), put in c# string, and then to make System.Windows.Media.Geometry
object.
This way is very good, it works perfect:
System.Windows.Media.Geometry g = Geometry.Parse("M 263,99 ... Z");
But, it fails (in my hands) with multi-line paths, fills, and other symbols.
UPD:
string sourse_xaml_str =
@"
<?xml version="1.0" encoding="UTF-8"?>
<!--This file is compatible with Silverlight-->
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg8" Width="210" Height="297">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<!--Unknown tag: sodipodi:namedview-->
<!--Unknown tag: metadata-->
<Canvas Name="layer1">
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path10" Fill="#FFFF5555" StrokeThickness="0.26458332" Data="m 74.083331 126.9107 -10.873824 18.802 9.324097 19.61673 -21.241956 -4.53148 -15.775318 14.92964 -2.254427 -21.6026 -19.073781 -10.38971 19.848644 -8.81966 3.987074 -21.35084 14.521563 16.15176 z"/>
</Canvas>
</Canvas>
";
System.Windows.Media.Geometry top_menu_item_icon = XamlReader.Parse( sourse_xaml_str ) as System.Windows.Media.Geometry;
Console.WriteLn( XamlReader.Parse( sourse_xaml_str ).ToString() );
Results:
top_menu_item_icon
==null
WriteLn()
show this:System.Windows.Controls.Canvas
So, it still not works for me.