Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RectangleGeometry.Rect Property

Gets or sets the dimensions of the rectangle.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
member Rect : Rect with get, set
<object>
  <object.Rect>
    <Rect .../>
  </object.Rect>
</object>
<object Rect="Rect" .../>

Property Value

Type: System.Windows.Rect
The position and size of the rectangle. The default is Empty.

Identifier field

RectProperty

Metadata properties set to true

None

This example describes how to use the RectangleGeometry class to describe a rectangle.

The following example shows how to create and render a RectangleGeometry. The relative position and the dimensions of the rectangle are defined by a Rect structure. The relative position is 50,50 and the height and the width are both 25 creating a square. The rectangle's interior is painted with a LemonChiffon brush and its outline is painted with a Black stroke with a thickness of 1.

<Path Fill="LemonChiffon" Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <RectangleGeometry Rect="50,50,25,25" />
  </Path.Data>
</Path>
No code example is currently available or this language may not be supported.
RectangleGeometry

A RectangleGeometry

Although this example used a Path element to render the RectangleGeometry, there are many other ways to use RectangleGeometry objects. For example, a RectangleGeometry can be used to specify the Clip of a UIElement or the Geometry of a GeometryDrawing.

Other simple geometry classes include LineGeometry and EllipseGeometry. These geometries, as well as more complex ones, can also be created using a PathGeometry or StreamGeometry.

More Code

How to: Animate a Rectangle Geometry by Using Key FramesThis example shows how to animate the Rect property of a RectangleGeometry by using key frames.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.