我想在按钮的代码中进行以下设置。
<Button.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="DarkSlateGray" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Button.Background>
有谁知道怎么做?
答案 0 :(得分:1)
可能是这样的:
var brush = new LinearGradientBrush {EndPoint = new Point(0.5, 1), StartPoint = new Point(0.5, 0)};
brush.GradientStops.Add(new GradientStop {Color = Color.FromArgb(0xFF, 0x2F, 0x4F, 0x4F), Offset = 0});
brush.GradientStops.Add(new GradientStop {Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), Offset = 1});
TheButton.Background = brush;