问题
In WPF I used to have my vector icons in ResourceDictionary like this:
<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>
and reference it from application like this:
<Path Data="{StaticResource BackIconGeometry}" Style="..." />
In UWP I'm getting error:
A value of type 'String' cannot be added to a collection or dictionary of type 'PathFigureCollection'
How can I store my icons data in resource dictionaries? I would like to avoid storing them as <Style TargetType="Path" /> since I would like to use different styles for the icons
回答1:
Your Path is an actual string value that is used for Binding so instead of using PathGeometry use x:String in resource Dictionary.
<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>
and in XAML you can use like below.
<Path Data="{StaticResource BackIconGeometry}" />
来源:https://stackoverflow.com/questions/41020372/pathgeometry-in-resourcedictionary