Search code examples
wpfcolorsbackground-colorgradient

Change background color with color gradients


I want to change the background color from my combobox. But I would like to retain the color gradients.

enter image description here

I've tried using this code but still does not get the effect.

<Setter Property="Background" Value="White"/> <!-- It's only white :( -->

Solution

  • <ComboBox>
        <ComboBox.Background>
            <LinearGradientBrush EndPoint="0,1">
                <GradientStopCollection>
                    <GradientStop Color="Blue" Offset="0.5" />
                    <GradientStop Color="White" Offset="0.5" />
                </GradientStopCollection>
            </LinearGradientBrush>
        </ComboBox.Background>
    </ComboBox>
    

    This will change the background color. Change the Color and Offset to get your desired result.