Xiol
Xiol

Reputation: 169

Add WPF Geometry from resource to GeometryGroup

So i know that i can do this

<Path Grid.Column="0" Width="16" Height="16" Fill="{DynamicResource WindowForegroundBrush}" Stretch="Uniform">
    <Path.Data>
        <GeometryGroup >
            <Geometry>some geometry data1</Geometry>
            <Geometry>some geometry data2</Geometry>
            <Geometry>some geometry data3</Geometry>
        </GeometryGroup>
    </Path.Data>
</Path>

But now i would like to move Geometry data 1, 2 and 3 into a resource dictionary

---resource dictionary---

<Geometry x:Key="data1">some geometry data1</Geometry>
<Geometry x:Key="data2">some geometry data2</Geometry>
<Geometry x:Key="data2">some geometry data3</Geometry>

---resource dictionary end---

<Path Grid.Column="0" Width="16" Height="16" Fill="{DynamicResource WindowForegroundBrush}" Stretch="Uniform">
    <Path.Data>
        <GeometryGroup >

        </GeometryGroup>
    </Path.Data>
</Path>

How do i add the geometry from my resources to my geometrygroup? Is ther some kind of binding or styling i could do?

I would prefere xaml only solution but all solutione are welcome.

Hope this make sens.

Upvotes: 4

Views: 1602

Answers (1)

Clemens
Clemens

Reputation: 128061

This should work:

<Path ...>
    <Path.Data>
        <GeometryGroup>
            <StaticResource ResourceKey="data1"/>
            <StaticResource ResourceKey="data2"/>
            <StaticResource ResourceKey="data3"/>
        </GeometryGroup>
    </Path.Data>
</Path>

Upvotes: 5

Related Questions