用颜色渐变更改背景颜色
问题描述:
我想更改我的组合框的背景颜色。 但我想保留颜色渐变。用颜色渐变更改背景颜色
我使用此代码尝试,但仍然没有得到效果。
<Setter Property="Background" Value="White"/> <!-- It's only white :(-->
我该如何解决这个问题?
答
<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>
这会改变背景颜色。更改颜色和偏移以获得所需的结果。