WPF Combobox Mouse Over

How to customize the Combobox style so that it looks like a mouse is hovering over it?

enter image description here

Currently it looks like this:

enter image description here

I tried this:

<Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="White" /> </Trigger> </Style.Triggers> 

But that did not work.

Update, this is what I have when I right-click on the combo box:

enter image description here

0
source share
1 answer

Blend gave me these colors:

 <SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#FF000000"/> <LinearGradientBrush x:Key="ComboBox.MouseOver.Background" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFECF4FC" Offset="0.0"/> <GradientStop Color="#FFDCECFC" Offset="1.0"/> </LinearGradientBrush> <SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/> <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#FFFFFFFF"/> <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/> <LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFEBF4FC" Offset="0.0"/> <GradientStop Color="#FFDCECFC" Offset="1.0"/> </LinearGradientBrush> <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/> 

These are the blue colors that you get.
If you right-click on the ComboBox icon, then Edit Template -> Edit a Copy... , you can change the color to whatever you want. Find MouseOver entries.

Edit template

The code can be inserted anywhere. In my example, this is inside <Window.Resources> :

 <Window.Resources> ... <SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/> <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#FFFFFFFF"/> <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/> <LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#FFEBF4FC" Offset="0.0"/> <GradientStop Color="#FFDCECFC" Offset="1.0"/> </LinearGradientBrush> <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/> ... </Window.Resources> 

This is just an example!

This is a fairly large piece of code, but this is the part you want to change.

+1
source

Source: https://habr.com/ru/post/982834/


All Articles