设置ComboBox选择项目高亮颜色 [英] Set ComboBox selected item highlight color
问题描述
我需要在弹出列表中更改ComboBox所选项目的突出显示颜色。我发现几个教程解释如何做到这一点,但所有他们使用Blend,我没有,无法获得,或涉及更改系统默认颜色,这似乎是一个黑客。
I need to change the highlight color of a ComboBox's selected item in the popup list. I've found several tutorials explaining how to do this, but all of them either use Blend, which I do not have and cannot obtain, or involve changing the system default colors--which seems like a hack to me.
有人可能指向我需要重写的模板,或告诉我需要设置的属性?
Can someone point me to the template I need to override, or tell me the property I need to set?
推荐答案
如果需要,覆盖 SystemColors.HighlightBrushKey
(和 SystemColors.HighlightTextBrushKey
): / p>
Override the SystemColors.HighlightBrushKey
(and SystemColors.HighlightTextBrushKey
if you want):
<ComboBox>
<ComboBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Red</SolidColorBrush>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}">Blue</SolidColorBrush>
</ComboBox.Resources>
<ComboBoxItem>One</ComboBoxItem>
<ComboBoxItem>Two</ComboBoxItem>
</ComboBox>
这篇关于设置ComboBox选择项目高亮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!