CHANGE BUTTON COLOR WHEN DISABLED

ben reitman

Total Post:96

Points:676
Posted by  ben reitman
 1378  View(s)
Ratings:
Rate this:

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" />

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Change button color when disabled

    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>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!