Naive solution : Just add a brush to the resources and refer to it from the Background property (via the StaticResource binding) of the ComboBox:
<Window x:Class="WpfApplication2.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"> <Window.Resources> <SolidColorBrush x:Key="BackgroundColorKey" Color="Red"/> <Style TargetType="{x:Type ComboBox}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="{StaticResource BackgroundColorKey}" /> </Trigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <ComboBox Height="25"/> </Grid>
Problem : After selecting an item, the background color reset returns to the default color. The only solution to fix this is to override the default template for combobox.
Fix : Change the default ComboBox template. The default template for ComboBox is present in msdn. Here is the link - http://msdn.microsoft.com/en-us/library/ms752094(v=vs.100).aspx . See "Example ComboBox ControlTemplate Schema".
Related links:
MouseOver highlighting style returning to standard after the second (called by Aero?)
http://social.msdn.microsoft.com/Forums/en/wpf/thread/a18891e9-8879-4819-9679-247341782f60
source share