I have ResourceDicionaryIcon where i store icons like DrawingBrush. And i want to change Brush color from {DynamicResource GreyBrush} to something that will allow me to choose color in control template button (Same color as text).
<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>
Actually i dislpay icon in Canvas like background. But thats not allow me to choose color. Is there any better solution how can i do this?
<Canvas x:Name="canvas" (...) Background="{TemplateBinding Background}" />
EDIT:
<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" (...)/>
I guess you should put your
Binding
backward like this:Here I my binding
Brush
to upper/parent elementI don't have Visual Studio right now to check this colution. Please correct me if I wrong