I have two buttons within a Toolbar and I would like the button's opacity to change, if the Button isEnabled=false
I define the Style and a trigger in the Resources of my Window:
<Window.Resources>
<Style x:Key="buttonOpacity" TargetType="Button">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.3" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
And here the Style should be applied:
<ToolBar>
<Button Click="FirstClick"
IsEnabled="False">
<Image Height="24" Source="Ressources/First.png"/>
</Button>
<Button Click="SecondClick"
IsEnabled="False"
Style="{StaticResource buttonOpacity}">
<Image Height="24" Source="Ressources/Second.png"/>
</Button>
</ToolBar>
I noticed, that the first Button doesn't apply the style and therefore doesn't change the oppacity. Whereas the second Button applies the style I gave to it. So, why does my first button not find the Resource? TargetType is set... Search goes upwards the logical tree...
Later on, I tried something similar with a Button within a DataGridTemplateColumn:
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Click="thridButton"
IsEnabled="false"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
On the thridButton, even setting the style manually doesn't help. I'm pretty much lost... Can anyone see my mistake?
By the way: The IsEnabled Flag is set with Data Binding and a converter. since the Style works when the style is set manually, I don't think that the problem is there...