Export (0) Print
Expand All

RectangleGeometry Object

Describes a two-dimensional rectangular geometry.

XAML
<RectangleGeometry .../>
Scripting
To create an object using scripting, see CreateFromXAML.

Remarks

FillRule is technically a property inherited from the base Geometry class, but setting it has no effect on a RectangleGeometry.

Examples

The following example shows how to create and render a RectangleGeometry. The position and the dimensions of the rectangle are defined by a Rect value, provided as a string. The position is 50,50 and the height and width are both 25, which creates a square. The following illustration shows the output of the example.

A RectangleGeometry drawn at (50,50)

A RectangleGeometry drawn at (50,50)

XAML
<Canvas 
  xmlns="http://schemas.microsoft.com/client/2007"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <Path Fill="LemonChiffon" Stroke="Black" StrokeThickness="1">
    <Path.Data>
      <RectangleGeometry Rect="50,50,25,25" />
    </Path.Data>
  </Path> 
</Canvas>

See Also

Geometry Overview
Geometry
GeometryGroup

Community Additions

Show:
© 2015 Microsoft