我想知道是否有任何方法可以在 xamlPathFigure
的元素中使用 from 资源。PathGeometry
假设我有一个 ResourceDictionary 和两个PathFigure
对象,其中的“x:Key”属性分别等于“Figure1”和“Figure2”。我的目标是创建一个PathGeometry
withFigures
属性,其中填充了一个包含 Figure1 和 Figure2 的集合。我可以使用隐藏文件的代码轻松地做到这一点,但是我想知道是否有任何方法可以仅使用 xaml 来做到这一点。
<PathFigure IsClosed="True" StartPoint="2,9" x:Key="Figure1">
<ArcSegment Point="15,9" Size="6.5, 2"/>
<LineSegment Point="15,12"/>
<ArcSegment Point="2,12" Size="6.5, 2"/>
</PathFigure>
<PathFigure IsClosed="True" StartPoint="10,7" x:Key="Figure2">
<LineSegment Point="10, 2"/>
<LineSegment Point="13,2"/>
<LineSegment Point="13,7"/>
<ArcSegment Point="10,7" Size="2,2" IsLargeArc="True"/>
</PathFigure>
我现在可以创建一个PathGeometry
:
<PathGeometry FillRule="Nonzero" x:Key="1">
<PathFigureCollection>
//Here I want to put Figure1 and Figure2
</PathFigureCollection>
</PathGeometry>
我想我可以写一些MarkupExtension
来做以下事情,但我正在寻找最好的方法。感谢您的建议。