【发布时间】:2020-04-04 13:00:16
【问题描述】:
在我的 wpf 文档中,我制作了一个自定义组合框样式,如下所示:
<ComboBox Background="#222222" BorderBrush="Black" Grid.Column="1" Height="30" Width="250">
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#262626" />
</ComboBox.Resources>
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Style.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Background" Value="#262626" /> </Trigger> </Style.Triggers>
</Style>
</ComboBox.ItemContainerStyle>
<ComboBoxItem Foreground="White" Name="Item1">Item1
</ComboBoxItem>
<ComboBoxItem Foreground="White" Name="Item2">Item2</ComboBoxItem>
<ComboBoxItem Foreground="White" Name="Item3">Item3</ComboBoxItem>
<ComboBoxItem Foreground="White" Name="Item4">Item4</ComboBoxItem>
<ComboBoxItem Foreground="White" Name="Item5">Item5</ComboBoxItem>
<ComboBoxItem Foreground="White" Name="Item6">Item6</ComboBoxItem>
但是每当我将鼠标悬停在其中一个 ComboboxItems 上时,我仍然会获得默认的悬停颜色,那么如何将其移除并放置我的颜色?
我对编码比较陌生,因此我们将不胜感激。
【问题讨论】:
标签: wpf combobox mouseover styling