Search code examples
c#wpfcombobox

Why isnt my Background color working in a ComboBox


The only part of my Combo Box that isn't working is the Background Color. I want the whole thing to be yellow. But the collapsed part is still just gray.

<ComboBox Height="25" Width="125" Background="Yellow">
    <ComboBox.ItemContainerStyle>
        <Style TargetType="ComboBoxItem">
            <Setter Property="Background" Value="Yellow"/>
            <Setter Property="BorderBrush" Value="Yellow"/>
        </Style>
    </ComboBox.ItemContainerStyle>
    <ComboBoxItem Content="One"/>
    <ComboBoxItem Content="Two"/>
    <ComboBoxItem Content="Three"/>
</ComboBox>

Solution

  • Your code should work as expected while using wpf with windows 7. However if you are running windows 8 or later, the same may not apply.

    This https://blog.magnusmontin.net/2014/04/30/changing-the-background-colour-of-a-combobox-in-wpf-on-windows-8/ might help you in achieving what you want.

    The author has given a very good explanation regarding the same.