将 WPF Geometry 从资源添加到 GeometryGroup

Xio*_*iol 4 c# wpf xaml

所以我知道我可以做到这一点

<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>
Run Code Online (Sandbox Code Playgroud)

但现在我想将几何数据 1、2 和 3 移动到资源字典中

---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>
Run Code Online (Sandbox Code Playgroud)

如何将我的资源中的几何图形添加到我的几何图形组?我可以做某种绑定或造型吗?

我更喜欢 xaml 唯一的解决方案,但欢迎所有解决方案。

希望这是有道理的。

Cle*_*ens 5

这应该有效:

<Path ...>
    <Path.Data>
        <GeometryGroup>
            <StaticResource ResourceKey="data1"/>
            <StaticResource ResourceKey="data2"/>
            <StaticResource ResourceKey="data3"/>
        </GeometryGroup>
    </Path.Data>
</Path>
Run Code Online (Sandbox Code Playgroud)