WPF combobox colors
I'm changing the look of all ComboBox
es 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 Com开发者_开发问答boBox
it will briefly turn the color I defined as the mouse over color, and then turn into some other color (light blue)]
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>
精彩评论