This article shows how to create text annotations over an image, in a WPF application. The technique involves rendering a custom control in the adorner layer of an
Imageelement, allowing for in-place editing of annotations. The classes used in the demo application can be easily and freely used in other applications to achieve the same functionality.
When you read the newspaper and scribble a thought on the page, you are creating an annotation. The term “annotation” refers to a note which describes or explains part of another document. The Windows Presentation Foundation has built-in support for document annotations, as described here. It does not, however, provide out-of-the-box support for annotating images.
A while back I wrote a blog post about how to annotate an
Imageelement which happens to reside in a
Viewbox. This article takes that idea and generalizes it so that any
Imagecan be annotated, not just one contained within a
Viewbox. Another improvement seen in this article’s demo application is that the annotations are created “in-place”, as opposed to typing the annotation text in a
TextBoxsomewhere else in the user interface.