3

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

Liero
  • 25,216
  • 29
  • 151
  • 297

1 Answers1

2

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}" />
AVK
  • 3,893
  • 1
  • 22
  • 31
  • 1
    Oh, I've tried this before I asked, but I forgot to include the resource dictionary. My bad... – Liero Dec 07 '16 at 15:41