有谁知道当鼠标悬停在 WPF ComboBox 上时如何设置其背景属性的样式?
我无法摆脱像 ComboBox 背景那样的蓝色按钮。
最佳答案
你可以像其他任何东西一样设置它的样式:
<Style TargetType="{x:Type ComboBox}" x:Key="HoverBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Blue" />
</Trigger>
</Style.Triggers>
</Style>
用法:
<ComboBox Style="{StaticResource HoverBox}" ... />
并且在您的用户控件/窗口的顶部,您必须放置样式:
<UserControl...>
<UserControl.Resources>
<Style TargetType="{x:Type ComboBox}" x:Key="HoverBox">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Blue" />
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
[CONTENT HERE]
</UserControl>
关于c# - 无法在鼠标悬停时设置 WPF ComboBox 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5563536/