WPF button canexecute style?

1.4k Views Asked by At

My first time setting "CanExecute" to anything other than "True"... I don't like the default grey background on my button when "CanExecute" is false.

For example I would like to change the background to "Red" if "CanExecute" is "False" (assuming "CanExecute" manipulated the IsEnabled property, which doesn't seem correct). Any advice is appreciated. If there is a good link to get beginner-level answers to this kind of question that would be appreciated too.

I just copied and tried to modify this example, not sure how close it is to being correct:

<Button Content="Update" 
        CommandParameter="{Binding ID}"
        Command="{Binding UpdateCommand}" >
     <Button.Style>
          <Style TargetType="Button">
               <Style.Triggers>
                   <Trigger Property="IsEnabled" Value="false">
                        <Setter Property="Background" Value="Red" />
                   </Trigger>
               </Style.Triggers>
           </Style>
     </Button.Style>
</Button>
0

There are 0 best solutions below