Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: Is it standard that when a menuitem is disabled the icon is not greyed out?

Tags:

command

icons

wpf

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?

like image 732
Brad Avatar asked Mar 08 '10 20:03

Brad


2 Answers

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>
like image 59
KornMuffin Avatar answered Sep 18 '22 03:09

KornMuffin


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

like image 8
Jobi Joy Avatar answered Sep 18 '22 03:09

Jobi Joy