using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfCropImage1 { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); //Change_Background(); LinearGradientBrush ld = new LinearGradientBrush(); ld.StartPoint = new Point(0, 0); ld.EndPoint = new Point(1, 1); ld.GradientStops.Add( new GradientStop(Colors.Yellow, 0.0)); ld.GradientStops.Add( new GradientStop(Colors.Red, 0.25)); ld.GradientStops.Add( new GradientStop(Colors.Blue, 0.75)); ld.GradientStops.Add( new GradientStop(Colors.LimeGreen, 1.0)); App app1 = (App)Application.Current; app1.Resources.Add("custombackground", ld); // Overriding Default background Azure win.Title = "Croping images"; // win.Background = (LinearGradientBrush)grid1.FindResource("custombackground"); grid1.Background= (LinearGradientBrush) grid1.FindResource("custombackground"); } } }