Chapter 12. Control basics and UserControls

 

This chapter covers

  • Understanding the control base types
  • Working with button controls
  • Working with items controls
  • Creating your own UserControls
  • Implementing dependency properties

The previous chapter covered the basics of text, including how to display and edit it. Two of the items discussed—TextBox and RichTextBox—are controls. The TextBlock isn’t.

If you’re coming from another technology, you may assume that anything you can see or interact with is a control, and you’d be partially right. Interaction generally requires a Control, but seeing something such as a TextBlock requires only that it be a UIElement (covered in chapter 7).

In this chapter you’ll explore the base control types Control and Content-Control, then dive into the various types of controls, including Button controls and ItemsControls. In your Silverlight travels, you’ll find that understanding these categories of controls will be pretty much all you need to make sense of any new control you run across.

Toward the end of this chapter, you’ll also take your first trip into creating controls of your own. In this case, you’ll follow the simple reuse model: the UserControl. I covered the UIElement and FrameworkElement in chapter 7, so let’s continue our walk up the stack and take a look at the base Control type.

12.1. Control

12.2. ContentControl

12.3. Button controls

12.4. ItemsControls

12.5. Creating UserControls

12.6. Summary