Creating a custom (templated) control

User controls are great for encapsulating a piece of UI functionality that can be easily reused. Their potential disadvantage is the lack of deep customization. In case such customization is required (or at least anticipated), a custom control should be built. This is a class deriving from Control, that provides a default look (through a control template), but that template can be changed if needed, without harming the control's functionality. In fact, this is how all WPF controls work – they provide some default template (look), but we can replace that template while preserving the control's behavior, as we've seen in Chapter 8, Styles, Triggers, and Control Templates.

In this recipe, we'll take a look at ...

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.