Creating Custom Controls

An alternative way of creating a reusable control is to create a custom control. Custom controls are structured quite differently than user controls, imposing a much stricter separation of their look (defined in XAML), and their behavior (defined in code). This strict separation between the control's look and behavior enables the controls to be retemplated (have their look completely redefined) when they are used. To enable a custom control to be retemplated, you need to provide a formal contract between them using the parts and states model, as discussed back in Chapter 9.

When you should create a custom control instead of a user control is a difficult line to define. One of the advantages of a custom control is that ...

Get Pro Business Applications with Silverlight 5 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.