Information
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

Draws a rectangle.

Namespace:  System.Windows.Shapes
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

'Declaration
Public NotInheritable Class Rectangle _
	Inherits Shape
'Usage
Dim instance As Rectangle
<Rectangle .../>

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 
Dim myRect As New Rectangle()
myRect.Stroke = Brushes.Black
myRect.Stroke = Brushes.Black
myRect.Fill = 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

Show:
© 2014 Microsoft