40 lines
864 B
C#
40 lines
864 B
C#
using System.Windows;
|
|
using System.Windows.Media;
|
|
|
|
namespace WPF基础_1;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
var brush = new LinearGradientBrush();
|
|
|
|
var gradientStop1 = new GradientStop
|
|
{
|
|
Offset = 0,
|
|
Color = Colors.Red
|
|
};
|
|
brush.GradientStops.Add(gradientStop1);
|
|
|
|
var gradientStop2 = new GradientStop
|
|
{
|
|
Offset = 0.5,
|
|
Color = Colors.Indigo
|
|
};
|
|
brush.GradientStops.Add(gradientStop2);
|
|
|
|
var gradientStop3 = new GradientStop
|
|
{
|
|
Offset = 1,
|
|
Color = Colors.Violet
|
|
};
|
|
brush.GradientStops.Add(gradientStop3);
|
|
|
|
Grid.Background = brush;
|
|
}
|
|
} |