* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.8 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Define a Rectangle Using a RectangleGeometry | 03/30/2017 |
|
|
e40b8a8e-54b8-416b-a9f2-be6dca9fdf0b |
How to: Define a Rectangle Using a RectangleGeometry
This example describes how to use the xref:System.Windows.Media.RectangleGeometry class to describe a rectangle.
Example
The following example shows how to create and render a xref:System.Windows.Media.RectangleGeometry. The relative position and the dimensions of the rectangle are defined by a xref:System.Windows.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 xref:System.Windows.Media.Brushes.LemonChiffon%2A brush and its outline is painted with a xref:System.Windows.Media.Brushes.Black%2A stroke with a thickness of 1.
[!code-xamlGeometryOverviewSamples_snip#GraphicsMMRectangleGeometryExample]
[!code-csharpGeometryOverviewSamples_procedural_snip#GraphicsMMRectangleGeometryExample] [!code-vbGeometryOverviewSamples_procedural_snip#GraphicsMMRectangleGeometryExample]
Although this example used a xref:System.Windows.Shapes.Path element to render the xref:System.Windows.Media.RectangleGeometry, there are many other ways to use xref:System.Windows.Media.RectangleGeometry objects. For example, a xref:System.Windows.Media.RectangleGeometry can be used to specify the xref:System.Windows.UIElement.Clip%2A of a xref:System.Windows.UIElement or the xref:System.Windows.Media.GeometryDrawing.Geometry%2A of a xref:System.Windows.Media.GeometryDrawing.
Other simple geometry classes include xref:System.Windows.Media.LineGeometry and xref:System.Windows.Media.EllipseGeometry. These geometries, as well as more complex ones, can also be created using a xref:System.Windows.Media.PathGeometry or xref:System.Windows.Media.StreamGeometry.
