【发布时间】:2020-07-16 16:57:25
【问题描述】:
我创建了一个包含多个类的资源字典
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Something_GUI">
<PathGeometry x:Key="DeleteIcon" Figures="M93.05,47.59A2.08,2.08,0,0,0,91,45.51a2,2,0,0,0-.68.13h0l0,0-.1,0C82.9,48.24,70,51.13,
48.58,51.13c-20.27,0-32.93-2.59-40.37-5a2.28,2.28,0,0,0-.83-.17,2.07,2.07,0,0,0-2,1.82l0,.06,
4.87,76.56c0,3.17,2.82,4.8,3.93,5.43,1.4.82,6.74,6.15,35.08,6.15s33.68-5.33,35.08-6.15c1.11-.63,
3.93-2.26,3.93-5.43L93.05,47.8l0,0C93,47.72,93.05,47.65,93.05,47.59ZM48.42,80a5.59,5.59,0,1,1-5.59,
5.59A5.59,5.59,0,0,1,48.42,80ZM32.24,118a5.59,5.59,0,1,1,5.59-5.59A5.59,5.59,0,0,1,32.24,118ZM34.6...
现在在另一个 XAML 页面中,我已经合并了我的 ResourceDictionary,我正在尝试使用以下代码绘制此图标
<DrawingImage>
<DrawingImage.Drawing>
<GeometryDrawing >
<GeometryDrawing.Geometry>
<PathGeometry/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>
我的意图是使用我已经在 ResourceDictionary.xaml 中定义的 PathGeometry,但我还没有找到引用它的方法。我不能打电话给<PathGeometry Figures="{StaticResource myIcon}",也找不到像<GeometryDrawing.Geometry Data={} /> 或<GeometryDrawing.Geometry PathGeometry={} /> 这样的东西,我可以用它们来直接引用我正在尝试使用的对象。我已经搜索了该主题,但尚未找到任何答案。
有没有办法从资源字典中引用整个对象?
【问题讨论】:
-
请注意,您可能还想使用路径:
<Path Data="{StaticResource DeleteIcon}" Fill="Black"/> -
我会使用路径,但在这种情况下对我来说是不可能的。我正在使用 DevExpress,但不支持 BarItem.Glyph 属性路径。