I'm having a strange error with a simple PathGeometry object and I can't seem to figure it out. I would appreciate it if someone could explain to me why this doesn't work.
Here is an example of a working Path, which draws a small triangle:
<Path Data="M 8,4 L 12,12 4,12 8,4 Z" Stroke="White" />
Here is an example of a Path that does not seem to work for me:
<Path Stroke="White">
<Path.Data>
<PathGeometry Figures="M 8,4 L 12,12 4,12 8,4 Z" />
</Path.Data>
</Path>
The string in the Data and Figures properties are identical, yet the latter example results in the exception:
Invalid attribute value M 8,4 L 12,12 4,12 8,4 Z for property Figures.
What I would like to do ultimately is to put the PathGeometry into a ResourceDictionary and reference it as a {StaticResource} so I can re-use my shapes.
Edit:
My solution was to instead of trying to reference a PathGeometry with a StaticResource, to instead reference a string resource.
<sys:String x:Key="TriangleShape">M 8,4 L 12,12 4,12 8,4 Z</sys:String>
...
<Path Data={StaticResource TriangleShape}" />
From what I can tell, path markup syntax, as used by Path.Data, isn't supported by PathGeometry. The PathGeometry.Figures property has to be a collection of PathFigure objects instead.
To specify the above shape in this way, you could do something like the following:
Disclaimer: I haven't tried this on WP7, only on Silverlight on my PC.