Chapter 18. Drawing with Shapes

What You’ll Learn in This Hour:

  • Using Shapes

  • Drawing with the Path element

  • Understanding stroke and fill

  • Working with complex shapes

Just like the rest of WPF, the API for 2D drawing is both extensive and powerful. Our goal in this hour is to equip you with the basics you need to start working with WPF quickly, as well as providing a foundation for learning if your projects have a need to go deeper.

Drawing Basic Shapes

The WPF has a number of basic shapes built in. The shapes are

  • Line

  • Polyline

  • Polygon

  • Rectangle

  • Ellipse

  • Path

All these classes live in the namespace System.Windows.Shapes.

Lines and Strokes

The best way to understand how these shapes work is to see them in action. Let’s create a simple project for the purpose of understanding ...

Get Sams Teach Yourself WPF in 24 Hours now with O’Reilly online learning.

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