Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12.  
  13. namespace ClearspanSilverlight
  14. {
  15.     public partial class MainPage : UserControl
  16.     {
  17.  
  18.         public void CreateARectangle()
  19.         {
  20.             // Create a Rectangle
  21.             Rectangle blueRectangle = new Rectangle();
  22.             blueRectangle.Height = 100;
  23.             blueRectangle.Width = 200;
  24.  
  25.             // Create a blue and a black Brush
  26.             SolidColorBrush blueBrush = new SolidColorBrush();
  27.             blueBrush.Color = Colors.Blue;
  28.             SolidColorBrush blackBrush = new SolidColorBrush();
  29.             blackBrush.Color = Colors.Black;
  30.  
  31.             // Set Rectangle's width and color
  32.             blueRectangle.StrokeThickness = 4;
  33.             blueRectangle.Stroke = blackBrush;
  34.  
  35.             // Fill rectangle with blue color
  36.             blueRectangle.Fill = blueBrush;
  37.  
  38.             // Add Rectangle to the Grid.
  39.             LayoutRoot.Children.Add(blueRectangle);
  40.         }
  41.  
  42.  
  43.  
  44.  
  45.         public MainPage()
  46.         {
  47.             CreateARectangle();
  48.             InitializeComponent();
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement