WPF Controls Introduction


Windows Presentation Foundation (WPF) has a standard set of controls that enable you to easily assemble a modern application graphical user interface. There are many controls included “in the box”. How would you group all of these controls into categories? They can be roughly grouped into the following categories, as specified on page 242 of Adam Nathan’s book WPF 4.5 Unleashed by Sams Publishing, published in 2014 by Pearson Education.

  • Content Controls
  • Items Controls
  • Range Controls
  • Other Controls

Content Controls

These are controls that are constrained to contain a single item. There can be only one direct child, which can contain other controls.Content controls derive from System.Windows.Controls.ContentControl. The built-in content controls come in three major varieties.

  • Buttons
  • Simple Containers
  • Containers with Headers

A button is a content control that can be clicked but not double-clicked. This behaviour is in the abstract class ButtonBase. Several controls derive from ButtonBase: Button, RepeatButton, ToggleButton, CheckBox and RadioButton.

Simple containers include the Label, ToolTip and Frame.

Containers with Headers include the GroupBox and Expander.

Items Controls

Items controls are the other major category of WPF controls. Items controls contain a collection of items instead of a single piece of content. They derive from the abstract ItemsControl class. ItemsControl stores its content in an Items property of type ItemCollection. Each item can be an arbitrary object. For example, ListBox is an items control. ItemsControl has two main properties of interest: Items and ItemsSource. It also has HasItems, IsGrouping, AlternateCount, and AlterationIndex, DisplayMemberPath and ItemsPanel.

Selectors are items controls whose items can be indexed and selected. Version 4.5 of WPF ships with six Selector-derived controls.

  1. ComboBox
  2. ListBox
  3. ListView
  4. TabControl
  5. DataGrid
  6. Ribbon

Menus are another type of items control.

TreeView, Toolbar and StatusBar are neither selectors or menus but can still contain an unbound number of arbitrary objects, so they fall under the category of items controls.

Other Controls

The rest of the controls are neither content controls or items controls. We have a post here called Text

  1. Image control
  2. TextBlock
  3. Label
  4. TextBox
  5. RichTextBox
  6. PasswordBox
  7. InkCanvas
  8. ProgressBar
  9. Slider
  10. Calendar
  11. DatePicker