使用颜色渐变更改背景颜色

时间:2012-07-11 10:57:30

标签: wpf colors background-color gradients

我想从组合框中更改背景颜色。 但我想保留颜色渐变。

enter image description here

我尝试过使用此代码,但仍无效果。

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

1 个答案:

答案 0 :(得分:2)

<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>

这将改变背景颜色。更改颜色和偏移量以获得所需的结果。