Warpin
Warpin

Reputation: 7043

WPF combobox colors

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 whenIsEnabled=false

2) 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)]

Upvotes: 0

Views: 4537

Answers (1)

Jobi Joy
Jobi Joy

Reputation: 50028

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>

Upvotes: 2

Related Questions