I did a lot of search on this and end up no answer.
following are some of my search results:
Setting combo box foreground color for the disabled state
WPF combobox disabled background color
WPF ComboBox: background color when disabled
some people said it works, but some said no. and i tried, and i am with the first kind.
so how exactly to make it work? i searched msdn, and the answers are to copy and paste standard template then modify it.
sure it will work, but i just need to change the color. it's too complicated for a peanut.
i made myself a fast self contained xaml only program, and in my box, it doesn't work:
<Window x:Class="WpfApplication11.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ComboBox Margin="0,0,170,253">
<ComboBox.Style>
<Style TargetType="ComboBox">
<Setter Property="IsEnabled" Value="{Binding IsChecked, ElementName=tgb}"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" Value="#FF000000"/>
</Trigger>
<Trigger Property="IsEnabled" Value="true">
<Setter Property="Background" Value="#FF474747"/>
</Trigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
<ToggleButton x:Name="tgb" Margin="347,218,10,10"/>
</Grid>
</Window>
IsEnabled
toggle as the toggle button gets clicked, and when it's disabled, the combobox should be black, while it's not.
the most confusing part is, the trigger on IsEnabled
is true works but the one on false does not.
could somebody show me how to fix that?
i am now using .net 4.5.1, visual studio 2013.