Home > DeveloperSection > Forums > Change button color when disabled
ben reitman
ben reitman

Total Post:96

Points:676
Posted on    March-06-2014 11:11 PM

 ASP.NET MVC ASP.NET MVC 
Ratings:


 1 Reply(s)
 1080  View(s)
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" />



Pravesh Singh

Total Post:411

Points:2881
Posted on    March-06-2014 11:20 PM

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>


Don't want to miss updates? Please click the below button!

Follow MindStick