views:

19

answers:

1

I'm trying to create a resource Style for a Path (Shape), however, when creating several Paths that use the Style, only the first one is rendered.

//In resources xaml
<clr:String x:Key="path">M 50,50 L 35,15 A 8,10 0 0 1 65,15z</clr:String>
<Style TargetType="Path" x:Key="pathStyle">
    <Setter Property="Stroke" Value="Black">
</Style>
//in control xaml
<Grid>
    <Path Style="{StaticResource pathStyle}" Fill="Blue" Data="{StaticResource path}" >
    <Path Style="{StaticResource pathStyle}" Margin="60" Fill="Red" Data="{StaticResource path}">
</Grid>

Only the first Path in the XAML above will be rendered. I've read that this is currently how it's supposed to be. Is there any way to overcome this issue in a non-programmatic method?

A: 

I think you will find that one Path is placed directly over the other. Try adding some margin or placing them in a stackpanel.

AnthonyWJones
If that were the case, the LAST Path would be visible. That is NOT the case.
SirDemon
@SirDemon: Umm... well thats interesting but what I see is the Red one not the Blue one and if I add `Margin="60"` to the Red one I see both. Perhaps you should update your question with your _exact_ Xaml, the currently posted Xaml needs some tidying up to actually work at all.
AnthonyWJones
@AnthonyWJones, have you tried it outside of the Designer view? For me it shows perfectly well on the design view, but when running the project, only the first one is rendered.
SirDemon
@SirDemon: For me its the other way around the designer doesn't really know what to make of it but it works at runtime. However I have been able to reproduce your problem when I place the data geometry into the `Style` and removed the StaticResource on the `Data` property. It would seem that you can't share a single instance of a Geometry between multiple Paths (which is really disappointing).
AnthonyWJones