Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将整个XAML文件转换为System.Windows.Media.Geometry对象?_C#_Wpf_Xaml_Type Conversion - Fatal编程技术网

C# 如何将整个XAML文件转换为System.Windows.Media.Geometry对象?

C# 如何将整个XAML文件转换为System.Windows.Media.Geometry对象?,c#,wpf,xaml,type-conversion,C#,Wpf,Xaml,Type Conversion,如何:XAML->System.Windows.Media.Geometry 我想创建矢量图像(例如,在Inkscape中),将其保存到XAML,然后获取整个文件(从第一个“”),放入字符串,然后生成System.Windows.Media.Geometry对象 这条路很好,很完美: System.Windows.Media.Geometry g = Geometry.Parse("M 263,99 ... Z"); 但是,多行路径、填充和其他符号(在我手中)失败了 UPD: @“ ”

如何:
XAML
->
System.Windows.Media.Geometry

我想创建矢量图像(例如,在Inkscape中),将其保存到XAML,然后获取整个文件(从第一个“”),放入字符串,然后生成
System.Windows.Media.Geometry
对象

这条路很好,很完美:

 System.Windows.Media.Geometry g = Geometry.Parse("M 263,99 ... Z");
但是,多行路径、填充和其他符号(在我手中)失败了

UPD:

@“


System.Windows.Media.Geometry顶部菜单项图标=XamlReader.Parse(sourse\u xaml\u str)为System.Windows.Media.Geometry;
Console.WriteLn(XamlReader.Parse(sourse_xaml_str.ToString());
结果:

  • top\u菜单项\u图标
    =
    null
  • WriteLn()
    显示:
    System.Windows.Controls.Canvas

  • 因此,它对我仍然不起作用。

    我不熟悉Inkscape如何输出XAML,但您是否尝试过在运行时加载XAML文件?您可以发布Inkscape中一个小示例XAML文件的内容吗?谢谢您的想法。只需将所有内容打包到一个
    C#
    文件中。这就是为什么我要手动将整个文件放入字符串中。我使用了
    XamlReader
    ,但无法让它从字符串中读取。抱歉,使用它对我仍然不起作用。以前试过,现在试过,但没有结果。也找不到有关如何将
    画布
    转换为
    几何体
    string sourse_xaml_str =