I have many buttons, all of them have the other Content (Polygons, Rectangles, Ellipses etc)
Each Content's Fill and Stroke property use DynamicResources:
<SolidColorBrush x:Key="ContentsBorderColorEnabled" Color="Red"/>
<SolidColorBrush x:Key="ContentsBackgroundColorEnabled" Color="White"/>
<SolidColorBrush x:Key="ContentsBorderColorDisabled" Color="Gray"/>
<SolidColorBrush x:Key="ContentsBackgroundColorDisabled" Color="Gray"/>
An example of the Content:
<Rectangle x:Key="StopRect" Stroke="{DynamicResource ContentsBorderColorEnabled}" Fill="{DynamicResource ContentsBackgroundColorEnabled}" Width="8" Height="8"/>
And now, by the Style below I change the apperance of my button:
<Style x:Key="SimpleStop1" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Width="10" Height="10">
<ContentPresenter Content="{TemplateBinding Property = ContentControl.Content}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Control.Opacity" Value="0.5"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Stroke" TargetName="StopRect" >
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ContentsBorderColorDisabled}"/>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The problem is, when the Button's IsEnabled property is set to False I need to change f.eg the Content's Stroke and Fill. But somehow I cannot acces to it. How to resolve this problem ?
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Stroke" TargetName="StopRect" >
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ContentsBorderColorDisabled}"/>
</Setter.Value>
</Setter>
<Setter Property="Fill" TargetName="StopRect" >
<Setter.Value>
<SolidColorBrush Color="{DynamicResource ContentsBackgroundColorDisabled}"/>
</Setter.Value>
</Setter>
</Trigger>