I have a Rounded Border that contains a ComboBox
<Border CornerRadius="10" BorderBrush...>
<ComboBox Background="{x:Null}">
<ComboBoxItem ...>
<ComboBoxItem ...>
</ComboBox>
</Border>
When my mouse is not hovering on top of the Combobox, it looks nice and transparent. Like this:
When the mouse hovers on it, it then produce the old, Button-like, background, like this:
I would like the ComboBox to have with a transparent background even when mouse is hoving on top. I tried various ways including writing MouseEnter, MouseLeave, MouseMove to set the background to null, but with no success.
private void ComboBox_MouseEnter(object sender, RoutedEventArgs e)
{
comboBox1.Background = null;
}
I then try to set the Styling:
<Window.Resources>
<Style TargetType="{x:Type ComboBox}" x:Key="HoverBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Pink" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
that didn't work either. Then I tried modifying the control template:
<ControlTemplate TargetType="{x:Type ComboBox}" x:Key="MouseHover">
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red" />
<Setter Property="Foreground" Value="Green" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Worst, after I modify the Control template the ComboBox disappear, like follow:
I have done everything possible, but I am still getting that ugly button-background on my ComboBox whenever my mouse is hover on it.
Anyone knows what's going wrong here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…