我们有一组存储在资源字典中的SVG。
例如:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DrawingImage x:Key="Bell">
<DrawingImage.Drawing>
<DrawingGroup Opacity="1">
<DrawingGroup.Children>
<DrawingGroup Opacity="1">
<DrawingGroup.Children>
<DrawingGroup Opacity="1">
<DrawingGroup.Children>
<GeometryDrawing Brush="#FF000000" Pen="{x:Null}">
<GeometryDrawing.Geometry>
<PathGeometry FillRule="Nonzero" Figures="........." />
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</ResourceDictionary>
如果您注意到GeometryDrawing Brush设置为#ff000000(黑色)。 我们面临的问题是允许视图在运行时显示此SVG并分配颜色(通过绑定)。
我们的窗口(视图)具有Resource Dictionary,其中包含Window.Resources中的图标。
我们正在寻找以下解决方案:
<Image Source="{StaticResource Bell}" Fill="#FF884422"/>