views:

537

answers:

3

I currently use this style for my ComboBox in WPF:

    <Style TargetType="ComboBox">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Background" Value="#303030"/>
        <Setter Property="BorderBrush" Value="#000000"/>
    </Style>

How can I change it to specify the background color when the ComboBox is disabled?

(this is a follow-up to this question: http://stackoverflow.com/questions/2385205/wpf-combobox-colors)

A: 
<Style TargetType="ComboBox">
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Background" Value="#303030"/>
    <Setter Property="BorderBrush" Value="#000000"/>
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="#101010"/>
        </Trigger>
</Style>
Charlie
Doesn't work for me... if I disable the ComboBox the background is still light gray.
Martin
A: 

Martin,

I've got the same problem. Setting

    <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="#101010"/>
    </Trigger>

Doesn't change a thing. Did you solve this problem?

André

André Bakker
Yes - this is the sample I used as a basis for my style: http://msdn.microsoft.com/en-us/library/ms752094%28v=VS.85%29.aspx
Martin
A: 

I ended up using the style used here as a base, and this did allow to set the background color when disabled:

http://msdn.microsoft.com/en-us/library/ms752094%28v=VS.85%29.aspx

Martin