views:

295

answers:

1

I'm changing the look of all ComboBoxes in my application by adding this style to App.xaml:

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

There are two colors that I haven't been able to set: 1) the background color when IsEnabled=false, and the highlight background color when the mouse is over the ComboBox.

How can I change these two colors?

[edit: it looks like the highlight color is not the same as the mouse over color, because when I move my mouse over the ComboBox it will briefly turn the color I defined as the mouse over color, and then turn into some other color (light blue)]

+2  A: 

You want to check Style Triggers . Also need to override the ItemContainerStyle to get rid of the default light blue selection color

<Style.Triggers>
  <Trigger Property="IsMouseOver" Value="true">
    <Setter Property="Background" Value="SomeColor" />
  </Trigger>
  <Trigger Property="IsEnabled" Value="false">
    <Setter Property="Background" Value="SomeOtherColor" />
  </Trigger>
</Style.Triggers>
Jobi Joy
The highlight doesn't quite work. I set color Red for IsMouseOver and it does turn red for about a quarter of a second, and then the highlight color turns to light blue (which is used to turn to directly).
Martin
I hope you put this style in to the ItemContainerStyle (Whcih is style for ComboBoxItem)
Jobi Joy