如何更改Combobox下拉面板的背景颜色 [英] How change the background color of the dropdown panel of Combobox

查看:198
本文介绍了如何更改Combobox下拉面板的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改组合框的drowpdown面板的背景颜色。
我正在使用WPF。
我读过这篇文章




我希望整个面板都是蓝色的,包括单个项目周围的小边框。
如何更改我的代码以解决我的问题?
谢谢

解决方案

你看到的是容器的边框颜色的缺失 。将 BorderBrush 值设置为 Blue ,以便 ItemContainerStyle 删除白色查找边框。


I want to change the background color of the drowpdown panel of the combobox. I'm using WPF. I've read this post

BackgroundColor Items ComboBox WPF

and I've written this code:

      <ComboBox
        Width="{StaticResource UnityX3}"
        styles:Typhography.TypeSize="Body1"
        Margin="12 0 0 0"
        Foreground="{StaticResource Viola1Brush}"
        DisplayMemberPath="AuthorName"
        SelectedItem="{Binding Path=ConsoleViewModel.AnswersViewModel.SelectedAuthor}"
        ItemsSource="{Binding ConsoleViewModel.AnswersViewModel.Authors}"
        Grid.Column="1">
        <ComboBox.ItemContainerStyle>
          <Style TargetType="{x:Type ComboBoxItem}">
            <Setter Property="Background" Value="Blue" />
          </Style>
        </ComboBox.ItemContainerStyle>
      </ComboBox>

I have obtained the result in the picture.

I want that the entire panel is blue, included the little border around the single item. How can I change my code in order to solve my problem? Thank you

解决方案

What you are seeing is a missing border color of the container. Set the BorderBrush value to the Blue for what is needed by the ItemContainerStyle to remove the White looking border.

这篇关于如何更改Combobox下拉面板的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆