Shapes

The System.Windows.Shapes namespace defines drawing primitives that act as elements in the user interface tree. WPF supports a variety of different shapes, and provides element types for each of them, which are shown in Table 13-1. These integrate with framework-level functionality such as layout, styling, and data binding. These services are not without their costs, so it's useful to be aware that the shape classes provide a layer of abstraction on top of a lower-level set of services. See the "Shape Objects Versus Geometries" sidebar for details.

Table 13-1. Shapes

Shape Type

Usage

Ellipse

An ellipse

Line

A single straight line

Path

A shape using any mixture of straight lines and curves

Polygon

A closed shape made from straight lines

Polyline

An open shape made from straight lines

Rectangle

A rectangle, optionally with rounded corners

Get Programming WPF, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.