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 WpfGrid1 { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Rectangle Rectangle1 = new Rectangle(); Rectangle1.Width = 50; Rectangle1.Height = 50; Rectangle1.Fill = Brushes.Blue; Rectangle Rectangle2 = new Rectangle(); Rectangle2.Width = 150; Rectangle2.Height = 150; SolidColorBrush mySolidColorBrush = new SolidColorBrush(); // Setting brush's color using RGB values. mySolidColorBrush.Color = Color.FromArgb(155, 10, 30, 155); Rectangle2.Fill = mySolidColorBrush; grid1.Children.Add(Rectangle1); grid2.Children.Add(Rectangle2); } } }