Creating adorners

Adorners are elements that exist in a distinct adorner layer, not part of the normal visual tree. All adorners in a particular layer always sit on top (higher Z index) of the element they adorn. This characteristic of adorners makes them an excellent choice for things such as selection handles, popup elements, and other special tasks where bothering with the normal visual tree is impossible or complicated at best.

In this recipe, we'll take a look at creating and using adorners to indicate selection.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create an application that draws a bunch of circles that can be dragged with the mouse. The currently selected circle will be marked with an adorner.

  1. Create ...

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.