我们有一组SVG存储在资源字典中。运行时XAML 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刷机设置为#FF000000(黑色)。 我们面临的问题是允许视图显示此SVG并在运行时分配颜色(通过绑定)
我们的窗口(视图)的资源字典中包含Window.Resources中的图标。
我们正在寻找像这样的解决方案:
<Image Source="{StaticResource Bell}" Fill="#FF884422"/>
这似乎是很多绒毛的,我个人只是[它们导出(http://www.mikeswanson.com/xamlexport/)为XAML并将它们转换为模板化的ContentControl,我可以将所有这些东西作为依赖属性传递给一个班轮中的子元素,并将这些模板存储在资源字典中。 –
这看起来像我要采取的路径,你有一个你可以分享的例子吗? – Ealianis
是的,我开会的时间只有一分钟,但我会在午餐后回到这个位置,一旦我得到秒,我会立即挂断。 –