How to change the background color of a selected ComboBox item? uwp

非 Y 不嫁゛ 提交于 2021-02-05 08:09:14

问题


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;

How the ComboBox is displayed prior to selecting any items:

The expanded ComboBox

The ComboBox with "2" as the selected item

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.


回答1:


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.



来源:https://stackoverflow.com/questions/48702522/how-to-change-the-background-color-of-a-selected-combobox-item-uwp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!