Using content controls

Content controls provide a flexible way of customizing the appearance of a control. The ContentControl class includes a Content property, of type object; meaning, it can be anything. A typical example is a Button. The Button inherits from ContentControl (not directly, but this is unimportant for this discussion). A typical button shows text, an image, or perhaps an image and text. But in fact, it can hold anything, such as a graphic drawing, a video playing, any combination of the above, or anything else. This is the power of ContentControl. Let's see how this works.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create several buttons (which are ContentControls) and show the various ways their ...

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.