Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 2.46 KB

how-to-create-a-shape-by-using-a-pathgeometry.md

File metadata and controls

34 lines (24 loc) · 2.46 KB
title description ms.date helpviewer_keywords ms.assetid
How to: Create a Shape by Using a PathGeometry
Learn how to create a shape using the PathGeometry class. PathGeometry objects are composed of one or more PathFigure objects.
03/30/2017
shapes [WPF], creating with PathGeometry class
graphics [WPF], shapes
49a4a8b7-e738-45be-8dac-b54a6d8f5b21

How to: Create a Shape by Using a PathGeometry

This example shows how to create a shape using the xref:System.Windows.Media.PathGeometry class. xref:System.Windows.Media.PathGeometry objects are composed of one or more xref:System.Windows.Media.PathFigure objects; each xref:System.Windows.Media.PathFigure represents a different "figure" or shape. Each xref:System.Windows.Media.PathFigure is itself composed of one or more xref:System.Windows.Media.PathSegment objects, each representing a connected portion of the figure or shape. Segment types include xref:System.Windows.Media.LineSegment, xref:System.Windows.Media.ArcSegment, and xref:System.Windows.Media.BezierSegment.

Example

The following example uses a xref:System.Windows.Media.PathGeometry to create a triangle. The xref:System.Windows.Media.PathGeometry is displayed using a xref:System.Windows.Shapes.Path element.

[!code-xamlGeometrySample#49]

The following illustration shows the shape created in the previous example.

A PathGeometry
A triangle created with a PathGeometry

The previous example showed how to create a relatively simple shape, a triangle. A xref:System.Windows.Media.PathGeometry can also be used to create more complex shapes, including arcs and curves. For examples, see Create an Elliptical Arc, Create a Cubic Bezier Curve, and Create a Quadratic Bezier Curve.

This example is part of larger sample; for the complete sample, see the Geometries Sample.

See also