Xaml 资源字典中的路径几何

Xaml 资源字典中的路径几何,xaml,uwp,Xaml,Uwp,在WPF中,我曾经在ResourceDictionary中使用向量图标,如下所示: <PathGeometry x:Key="BackIconGeometry">M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z</PathGeometry> <Path Data="{StaticResource BackIconGeometry}" Style="..." /> M9.5,0 L16,0 8

在WPF中,我曾经在ResourceDictionary中使用向量图标,如下所示:

<PathGeometry x:Key="BackIconGeometry">M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z</PathGeometry>
<Path Data="{StaticResource BackIconGeometry}" Style="..." />
M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z
并从应用程序中引用它,如下所示:

<PathGeometry x:Key="BackIconGeometry">M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z</PathGeometry>
<Path Data="{StaticResource BackIconGeometry}" Style="..." />

在UWP中,我得到一个错误:

无法将“String”类型的值添加到集合或字典中 类型为“PathFigureCollection”


如何在资源字典中存储图标数据?我希望避免将它们存储为
,因为我希望对图标使用不同的样式

您的路径是用于绑定的实际字符串值,因此不要使用
路径几何体
在资源字典中使用
x:string

<Application.Resources>
    <x:String x:Key="BackIconGeometry">M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z</x:String>
</Application.Resources>

M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z
在XAML中,您可以像下面这样使用

<Path Data="{StaticResource BackIconGeometry}" />

您的路径是一个用于绑定的实际字符串值,因此不要使用资源字典中的
PathGeometry
使用
x:string

<Application.Resources>
    <x:String x:Key="BackIconGeometry">M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z</x:String>
</Application.Resources>

M9.5,0 L16,0 8.75,7 22,7 22,11 8.75,11 16,18 9.5,18 0,9 z
在XAML中,您可以像下面这样使用

<Path Data="{StaticResource BackIconGeometry}" />


哦,在我问之前我已经试过了,但是我忘了包括资源字典。我的错…哦,在我问之前我已经试过了,但是我忘了包括资源字典。我的错。。。