Understanding Shapes

The simplest way to draw 2-D graphical content in a WPF user interface is to use shapes: dedicated classes that represent simple lines, ellipses, rectangles, and polygons. Technically, shapes are known as drawing primitives. You can combine these basic ingredients to create more complex graphics.

The most important detail about shapes in WPF is the fact that they all derive from FrameworkElement. As a result, shapes are elements. This has a number of important consequences:

  • Shapes draw themselves. You don't need to manage the invalidation and painting process. For example, you don't need to manually repaint a shape when content moves, the window is resized, or the shape's properties change.

  • Shapes are organized in the same ...

Get Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.