Creating a custom shape

Shapes are (mostly) simple elements deriving from the Shape abstract base class, which derives directly from FrameworkElement; shapes providing an inherent graphical representation that can easily be filled, stroked and stretched. Shapes are not controls – they have no template associated with them. They are, however, full elements, providing support for the full range of capabilities, including participation in layout, hit testing, and the multitude of properties and events that make working with these entities as easy as any control.

We can create new shapes by deriving from Shape, providing a new graphical representation, and taking advantage of the functionality provided by the base Shape class.

Getting ready

Make sure ...

Get Windows Presentation Foundation 4.5 Cookbook 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.