Advertise with us

Change button color when disabled

I use the following button and when isDisabled is true the button is transparent (here its always true for the example but in my program its bound to command...) what I want is that when the button is disabled the color remain the same just ligther, how can I achive that?

    <Button 

                             Width="100"

                             Height="25"

                             Background="#f0ab00"

                             Content="Run"

                             FontSize="16"

                             Foreground="#ffffff"

                             IsDefault="True"

                             Margin="10,0,20,0"

                             IsEnabled="false" />

Last updated:3/6/2014 11:20:50 PM

1 Answers

Pravesh Singh
Pravesh Singh

Hi Ben,


Try this:

<Style TargetType="{x:Type Button}">
    <Setter Property="Foreground" Value="#ffffff"/>
    <Setter Property="Background" Value="#f0ab00"/>       
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="false">
            <Setter Property="Background" Value="#f0aa00"/>
        </Trigger>
    </Style.Triggers>
</Style>

Last updated:3/6/2014 11:20:50 PM

Answer