I have menuitems with icons and when it is disabled the icon remains the same. Is it up to me to supply a disabled icon and, if so, does this also apply to menuitems bound to a command?
Found Jobi's answer helpful. Here's another way to accomplish the same thing using an Image Style and the MenuItem.Icon:
<MenuItem Header="Add ..." Command="{Binding AddCommand}" >
<MenuItem.Icon>
<Image Source="{StaticResource AddImage}" Style="{StaticResource EnableDisableImageStyle}"/>
</MenuItem.Icon>
</MenuItem>
And the Style:
<Style x:Key="EnableDisableImageStyle" TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.75"/>
<Setter Property="BitmapEffect">
<Setter.Value>
<BlurBitmapEffect Radius="2.0" KernelType="Gaussian"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
Yes it is totally up to you. Because you have provided an Icon file. So you need to create Style.Trigger on MenuItem to give disabled effect on that. Either do a Opacity =0.5 or switch image to a different .ico image while IsEnabled=False in the template
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With