The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
Rectangle Class
Visual Studio 2008
Draws a rectangle.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
The following example shows how to create a Rectangle element and set its properties by using code. For the complete sample, see WPF Shapes Gallery Sample.
// Add a Rectangle Element myRect = new System.Windows.Shapes.Rectangle(); myRect.Stroke = System.Windows.Media.Brushes.Black; myRect.Fill = System.Windows.Media.Brushes.SkyBlue; myRect.HorizontalAlignment = HorizontalAlignment.Left; myRect.VerticalAlignment = VerticalAlignment.Center; myRect.Height = 50; myRect.Width = 50; myGrid.Children.Add(myRect);
More Code
| How to: Draw a Rectangle | This example shows how to draw a rectangle by using the Rectangle element. |
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Community Additions
Show: