How change the background color of the dropdown pa

2019-07-20 14:48发布

问题:

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

回答1:

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.