--- title: "How to: Define a Rectangle Using a RectangleGeometry" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "graphics [WPF], rectangles" - "rectangles [WPF], creating with RectangleGeometry class" ms.assetid: e40b8a8e-54b8-416b-a9f2-be6dca9fdf0b --- # How to: Define a Rectangle Using a RectangleGeometry This example describes how to use the class to describe a rectangle. ## Example The following example shows how to create and render a . The relative position and the dimensions of the rectangle are defined by a 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 brush and its outline is painted with a stroke with a thickness of `1`. [!code-xaml[GeometryOverviewSamples_snip#GraphicsMMRectangleGeometryExample](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometryOverviewSamples_snip/CS/GeometryExamples.xaml#graphicsmmrectanglegeometryexample)] [!code-csharp[GeometryOverviewSamples_procedural_snip#GraphicsMMRectangleGeometryExample](~/samples/snippets/csharp/VS_Snippets_Wpf/GeometryOverviewSamples_procedural_snip/CSharp/GeometryExamples.cs#graphicsmmrectanglegeometryexample)] [!code-vb[GeometryOverviewSamples_procedural_snip#GraphicsMMRectangleGeometryExample](~/samples/snippets/visualbasic/VS_Snippets_Wpf/GeometryOverviewSamples_procedural_snip/visualbasic/geometryexamples.vb#graphicsmmrectanglegeometryexample)] ![A RectangleGeometry](./media/graphicsmm-rectangle.gif "graphicsmm_rectangle") RectangleGeometry Although this example used a element to render the , there are many other ways to use objects. For example, a can be used to specify the of a or the of a . Other simple geometry classes include and . These geometries, as well as more complex ones, can also be created using a or . ## See also - [Geometry Overview](geometry-overview.md) - [Create a Composite Shape](how-to-create-a-composite-shape.md) - [Create a Shape by Using a PathGeometry](how-to-create-a-shape-by-using-a-pathgeometry.md)