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



An ellipse


A single straight line


A shape using any mixture of straight lines and curves


A closed shape made from straight lines


An open shape made from straight lines


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.