Width Property

Rect.Width Property


Gets or sets the width of the rectangle.

Namespace:   System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

public double Width { get; set; }

Property Value

Type: System.Double

A positive number that represents the width of the rectangle. The default is 0.

Exception Condition

Width is set to a negative value.


Width is set on an Empty rectangle.

The Empty rectangle has a Width of NegativeInfinity. The Empty rectangle is read-only; its Width cannot not be changed.

The following example shows how to use a Rect structure to specify the dimensions and location of a rectangle using XAML.

The following example shows how to use code to create a rectangle and add it to the page. The example also illustrates how to find size and coordinate information about the new rectangle and render the information in a TextBox below the rectangle.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2015 Microsoft