Rect Constructor (Double, Double, Double, Double)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Initializes a Rect structure that has the specified x-coordinate, y-coordinate, width, and height.

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


Public Sub New ( _
    x As Double, _
    y As Double, _
    width As Double, _
    height As Double _
public Rect(
    double x,
    double y,
    double width,
    double height


  • x
    Type: System.Double
    The x-coordinate of the top-left corner of the rectangle.
  • y
    Type: System.Double
    The y-coordinate of the top-left corner of the rectangle.


Exception Condition

width or height are less than 0.



width and height can be negative if they are specified in XAML as part of the attribute string, with the result that the direction that the width or height applies to is inverted. For instance, a height of -20 will produce a Rect where the X,Y point is now the bottom left corner. However, the Rect constructor in the managed API does not permit negative values for width and height. You should adjust the coordinate reference of x,y, width and height such that the Rect can be specified using non-negative width and height values.

Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.