0
我有ResourceDicionaryIcon我在那裏存儲圖標像DrawingBrush。我想從{DynamicResource GreyBrush}將畫筆顏色更改爲允許我在控件模板按鈕(與文本顏色相同)中選擇顏色的內容。XAML圖標顏色
<DrawingBrush x:Key="icoEdit" Stretch="Uniform">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="{DynamicResource GreyBrush}" Geometry="F1 M 4.95279,30.227L 11.737,37.0113L 37.5279,11.2205L 30.7437,4.43622L 4.95279,30.227 Z "/>
<GeometryDrawing Brush="{DynamicResource GreyBrush}" Geometry="F1 M 31.7877,3.39215L 38.572,10.1764L 41.9641,6.78424L 35.1798,0L 31.7877,3.39215 Z "/>
<GeometryDrawing Brush="{DynamicResource GreyBrush}" Geometry="F1 M 10.6276,38.096L 0,41.9641L 3.86807,31.3365L 10.6276,38.096 Z "/>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
其實我在像背景畫布dislpay圖標。但那不允許我選擇顏色。有沒有更好的解決方案,我該如何做到這一點?
<Canvas x:Name="canvas" (...) Background="{TemplateBinding Background}" />
編輯:
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="grid" (...)>
(...)
<TextBlock Text="{TemplateBinding Content}" (...) Foreground="{TemplateBinding Foreground}"/>
<Canvas x:Name="canvas" (...) Background="{TemplateBinding Background}" (...)>
</Canvas>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Button x:Name="Button"
Style="{DynamicResource ButtonStyle}"
Foreground="#FF434341"
Background="{DynamicResource icoEdit}"
Content="BUTTON TEXT" (...)/>