Building a Basic User Control

A good way to get started with custom controls is to take a crack at creating a straightforward user control. In this section, we'll begin by creating a basic color picker. Later, you'll see how to refactor this control into a more capable template-based control.

Creating a basic color picker is easy—in fact, several examples are available online, one with the .NET Framework SDK and another with the Bag-O-Tricks custom control library that's provided by the WPF team. However, creating a custom color picker is still a worthy exercise. Not only does it demonstrate a variety of important control building concepts, but it also gives you a practical piece of functionality.

You could create a custom dialog box for your ...

Get Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.