wpf - 如何改变Combobox下拉面板的背景色

标签 wpf xaml drop-down-menu combobox background

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

BackgroundColor Items ComboBox WPF



我写了这段代码:
      <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>

我已经得到了图片中的结果。 enter image description here

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

最佳答案

您看到的是容器缺少边框颜色。设置 BorderBrush值到 Blue ItemContainerStyle 需要什么删除 White看边界。

关于wpf - 如何改变Combobox下拉面板的背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38094770/

相关文章:

c# - 如何实现双向数据绑定(bind)?

c# - 可见性的解决方法。隐藏状态 - Windows Phone 8.1 应用程序开发

asp.net - 在网页上创建下拉菜单的最简单方法?

c# - 如何为 WPF TreeView 设置垂直滚动条,而不是水平滚动条?

c# - WPF 图像控件源绑定(bind)

c# - 使用装饰器复制 UI 元素

Android微调器下拉菜单背景颜色更改

c# - DataGrid不会立即更新

.net - DataTemplate 作为具有可定制绑定(bind)的资源

html - 如何扩展我当前的 css 响应式下拉导航菜单?下拉没有按预期工作