Xamarin.Forms Guides | Samples

Xamarin.Forms.Rectangle Structure

Struct defining a rectangle, using doubles.

See Also: Rectangle

Syntax

[System.Diagnostics.DebuggerDisplay("X={X}, Y={Y}, Width={Width}, Height={Height}")]
[Xamarin.Forms.TypeConverter(typeof(Xamarin.Forms.RectangleTypeConverter))]
public struct Rectangle

Remarks

Application developers should be aware of the limits of floating-point representations, specifically the possibility of incorrect comparisons and equality checks for values with small differences. David Goldberg's paper What Every Computer Scientist Should Know About Floating-Point Arithmetic describes the issues excellently.

Note: Where Xamarin.Forms supports XAML for Rectangle structures, app devs can represent the rectangle as a comma-separated list of the X-coordinate, Y-Coordinate, Width, and Height.

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.4.0.0, 1.5.0.0, 2.0.0.0

The members of Xamarin.Forms.Rectangle are listed below.

See Also: ValueType

Public Constructors

Creates a new Rectangle object with its top left corner at loc with a height and width that are specified by sz.
Creates a new Rectangle object with its top left corner at (x, y) and width wide and height tall.

Public Fields

static
ZeroRectangle. The Rectangle at {0,0} whose Size is {0,0}.

Public Properties

BottomDouble. The bottom of the Rectangle.
[read-only]
CenterPoint. The Point halfway between Rectangle.Left and Rectangle.Right, Rectangle.Top and Rectangle.Bottom.
HeightDouble. Extent along the Y axis.
[read-only]
IsEmptyBoolean. Whether thisRectangle has either Rectangle.Height or Rectangle.Width less than or equal to 0.
LeftDouble. The position of the Rectangle on the X axis.
LocationPoint. The Point defined by Rectangle.Left and Rectangle.Top.
RightDouble. The furthest extent along the X axis.
SizeSize. The extent of the Rectangle along its X and Y axes.
TopDouble. The top of the Rectangle.
WidthDouble. The extent of this Rectangle along the X axis.
XDouble. The position of this Rectangle on the X axis.
YDouble. The position of this Rectangle on the Y axis.

Public Methods

Contains(Point) : Boolean
Whether the pt is within, or along the periphery, of this Rectangle.
Contains(Rectangle) : Boolean
Whether rect is entirely within, or along the periphery, of this Rectangle.
Contains(Double, Double) : Boolean
Whether the point described by x and y is within, or along the periphery of, this Rectangle.
override
Equals(Object) : Boolean
Whether an Object is a Rectangle and has exactly the same values as thisRectangle.
Equals(Rectangle) : Boolean
Whether a Rectangle has exactly the same values as thisRectangle.
static
FromLTRB(Double, Double, Double, Double) : Rectangle
Factory method to create a Rectangle from left, top, right, and bottom.
override
GetHashCode() : Int32
The hashcode for the Rectangle.
Inflate(Size) : Rectangle
Creates a Rectangle whose borders are inflated in every direction.
Inflate(Double, Double) : Rectangle
Creates a Rectangle whose borders are inflated in every direction.
Intersect(Rectangle) : Rectangle
A new Rectangle that is the intersection of this and r.
static
Intersect(Rectangle, Rectangle) : Rectangle
A new Rectangle that is the intersection of r1 and r2.
IntersectsWith(Rectangle) : Boolean
Whether thisRectangle intersects r.
Offset(Point) : Rectangle
A new Rectangle whose Rectangle.Location is offset by dr.
Offset(Double, Double) : Rectangle
A new Rectangle whose Rectangle.Location is offset by dx and dy.
Round() : Rectangle
Returns a new Rectangle whose values have been rounded to their nearest integral value.
override
ToString() : String
A human-readable description of the Rectangle.
Union(Rectangle) : Rectangle
A new Rectangle whose bounds cover the union of thisRectangle and r.
static
Union(Rectangle, Rectangle) : Rectangle
A new Rectangle whose bounds cover the union of r1 and r2.

Public Operators

static
Equality(Rectangle, Rectangle)Whether two Rectangles have equal values.
static
Inequality(Rectangle, Rectangle)Whether two Rectangles have unequal values.