Here's an extremely basic example of what I'm trying to do but does not work:
<StackPanel>
<StackPanel.Resources>
<Grid x:Key="MyYellowEllipse">
<Ellipse Width="50" Height="50" Fill="Yellow" />
</Grid>
<Grid x:Key="MyBlueEllipse">
<Ellipse Width="50" Height="50" Fill="Blue" />
</Grid>
</StackPanel.Resources>
<ContentPresenter Content="{StaticResource MyYellowEllipse}" />
<ContentPresenter Content="{StaticResource MyBlueEllipse}" />
<ContentPresenter Content="{StaticResource MyYellowEllipse}" />
<ContentPresenter Content="{StaticResource MyBlueEllipse}" />
<ContentPresenter Content="{StaticResource MyYellowEllipse}" />
<ContentPresenter Content="{StaticResource MyBlueEllipse}" />
</StackPanel>
For some reason when I do this, only the last two are populated (though space is left for the other). I would expect to be able to reuse the same content in multiple content presenters.
Why can't I do this, and more importantly, how should I be doing this instead if I want to achieve this.
I've built a bunch of custom glyphs using Path and Polygon objects in grids in a resource dictionary and I'd like to display them in multiple places in my app but they're only showing up in one usage (just like my example). I thought ContentPresenter was meant for this.
EDIT: It's a solution
@emoacht pointed out in the comments that adding x:Shared="False" to the Grid in the resource definitions will fix the problem. I'm going to use this solution for now.
For my own edification; however, I'd love if someone could explain to me A.) Why that's needed and B.) What the more appropriate solution to reusing a <Grid> with a bunch of <Polygon>s in it would be.

Because the default resource-retrieval behavior in WPF is to share an instance of a XAML resource for all requests. You can read more about this in the docs.
You could for an example define
MyYellowEllipseandMyBlueEllipseas a custom types:...and use them in your XAML markup like this without involving any resources:
You could obviously also create a base class called
MyEllipseor something for code-sharing reasons but you get the point.