如何更改所选 ComboBox 项目的背景颜色?超载 [英] How to change the background color of a selected ComboBox item? uwp
问题描述
我正在为 Windows 10 移动设备开发一个应用程序,我正在努力处理 ComboBox 控件的样式,更具体地说,是所选项目的背景颜色.
I'm developing an application for a Windows 10 Mobile device and I'm struggling to handle the styling for the ComboBox control, more specifically, the selected item's background color.
不编辑前景或背景属性控制;
Without editing the Foreground or Background properties of the control;
选择任何项目之前组合框的显示方式:
扩展的组合框
选择项为2"的组合框
我似乎找不到控件的任何属性,例如 SelectedItemBackgroundColor,更改 Foreground 和 Background 属性不会影响问题.
I can't seem to find any properties for the control such as SelectedItemBackgroundColor and changing the Foreground and Background properties doesn't affect the problem.
推荐答案
如果您查看 文档,可以看到ComboBoxItem
的默认样式使用SystemControlHighlightListAccentLowBrush
画笔作为SelectedItem的背景代码>.您可以在您的应用程序中重新定义此资源,也可以复制默认的
Style
并替换 Selected
VisualState
中的 Background
画笔> 使用自定义画笔.
If you look into the documentation, you can see the default style of ComboBoxItem
uses the SystemControlHighlightListAccentLowBrush
brush as the background of SelectedItem
. You can redefine this resource in your app or you can copy the default Style
and replace the Background
brush in Selected
VisualState
with a custom brush.
这篇关于如何更改所选 ComboBox 项目的背景颜色?超载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!