xaml代码如下:
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#3C3C3C"></GradientStop>
<GradientStop Offset="1" Color="#191919"></GradientStop>
</LinearGradientBrush>
</Grid.Background>
cs代码如下:
LinearGradientBrush linearGradientBrush = new LinearGradientBrush()
{
StartPoint = new Point(0, 0),
EndPoint = new Point(0, 1),
};
linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0x3c, 0x3c, 0x3c), 0));
linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0x19, 0x19, 0x19), 1));
BackGround = linearGradientBrush;
Visibility = Visibility.Collapsed;