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 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.