This appendix lists the Windows Presentation Foundation (WPF) controls that are available by default in the current version of .NET Framework 3.0, and briefly describes their purposes. This list does not include all of the hundreds of classes that WPF defines; it lists only the tools most likely to appear in the window designer’s Toolbox.
These controls are part of the System.Windows.Controls namespace. In contrast, the controls used in Windows Forms are contained in the System.Windows.Forms namespace. Many of the controls in the two namespaces serve very similar purposes, although they have different capabilities. For example, both namespaces have buttons, labels, combo boxes, and check boxes. Only the System.Windows .Controls classes provide foreground and background brushes, render transformations, complex content, and XAML-defined triggers.
This appendix describes the WPF controls in far less detail than Appendix G describes the Windows Forms controls. This is mostly attributable to time and space constraints, not because the WPF controls are inferior. These controls can do some amazing things that the Windows Forms controls cannot, such as containing other controls as content and applying transformations while drawing. Unfortunately, these new features would take at least a few hundred pages to cover in depth, and there just isn’t room in this edition of the book to do them justice.
Control | Purpose |
---|---|
Button | Displays a button that the user can click. |
CheckBox | Allows the user to select or deselect an item. |
ComboBox | Allows the user to select an item from a drop-down list. The list can contain all sorts of objects, but typically holds a series of ComboBoxItems. |
ComboBoxItem | Represents an item in a ComboBox control’s list. |
ContentControl | Represents a control that contains a single piece of content. Note, however, that the content may, in turn, contain other objects. |
ContextMenu | Builds a popup menu for a control. This element should be inside the control’s ContextMenu property (for example, inside a <Button.ContextMenu> element). MenuItem elements inside the ContextMenu define the menu’s items. |
DocumentViewer | Displays a FixedDocument. See the section “Fixed Documents” in Chapter 26. |
Expander | Displays a header and lets the user expand and contract a detail section. The <Expander.Header> sub-element contains the content displayed in the header. |
FlowDocumentPageViewer | Displays a FlowDocument one page at a time. See the section “Flow Documents” in Chapter 26. |
FlowDocumentReader | Displays a FlowDocument in single page, book reading, or scrolling mode. See the section “Flow Documents” in Chapter 26. |
FlowDocumentScrollViewer | Displays a FlowDocument as a single, long, vertically scrolling page. See the section “Flow Documents” in Chapter 26. |
Frame | Supports navigation and content display. The control can navigate to a .NET Framework 3.0 object or to HTML content. |
GridSplitter | Acts as a splitter that allows the user to resize rows or columns in a Grid. |
GridViewColumnHeader | Represents a column header for a GridViewColumn. |
GroupBox | Displays a visible border with a header. The Header property determines the content displayed in the header. It also forms a grouping for any RadioButtons that it contains. |
GroupItem | Used to group items in other controls such as a TreeView. |
HeaderedContentControl | This is the base class for controls that have a single content element and a header. Although you can create one directly, usually it’s better use a subclass such as GroupBox. |
HeaderedItemsControl | Displays a header and multiple content elements. |
ItemsControl | Displays a collection of content items. |
Label | Displays non-editable text. |
ListBox | Lets the user select items from a list. ListBoxItem objects hold the items. |
ListBoxItem | Holds content for display by a ListBox object. |
ListView | Displays a group of items in various display modes. |
ListViewItem | Contains the content for an item displayed in a ListView. |
Menu | Builds a menu that is visible, in contrast to a ContextMenu, which is hidden until displayed. MenuItem elements inside the Menu define the menu’s items. |
MenuItem | Defines a top-level menu, submenu, or menu item for a ContextMenu or Menu. |
NavigationWindow | Navigates to content and displays it, keeping a navigation history. Similar to Frame. |
PasswordBox | A text box where the user can enter sensitive information such as passwords. The control’s PasswordChar property determines the character displays for each character the user types. By default, this is a solid black circle. |
ProgressBar | Displays an operation’s progress. |
RadioButton | A group of RadioButton controls allows the user to select one of the buttons at a time. |
RepeatButton | A button that repeatedly raises Click events until it is released. |
ResizeGrip | Displays a resize grip similar to the one used on the lower-right corner of a window. |
RichTextBox | Enables the user to edit Rich Text content. |
ScrollBar | Displays a sliding thumb used to select a value, usually to scroll some sort of display or data. |
ScrollViewer | Makes a scrollable area that can contain other controls. |
Separator | Draws a vertical or horizontal separator in controls that contain other controls, such as StatusBar, Menu, ListBox, or ToolBar. |
Slider | Enables the user to select a value from a range by sliding a Thumb along a Track. |
StatusBar | Displays a series of items in a horizontal bar, typically along the bottom edge of a window to provide status information. |
StatusBarItem | Contains an item in a StatusBar. |
TabControl | Displays a series of tabs that have headers and content. |
TabItem | Represents an item in a TabControl. The Header property determines the content displays on the tab, and the Content property determines what’s displayed on the tab’s body. |
TextBox | Enables the user to enter text. |
Thumb | Represents an area that the user can grab and drag as in a ScrollBar or Slider. |
ToggleButton | This is the base class for controls that toggle between two states such as a CheckBox or RadioButton. You can make one directly, but it’s easier to use CheckBox or RadioButton. |
ToolBar | Contains a series of tools, typically Button controls, ComboBox controls, and other small controls. The Header property gives the ToolBar a header. |
ToolTip | Creates a popup tooltip to provide hints about a control’s usage. |
TreeView | Displays hierarchical data with a series of nested collapsible nodes. TreeViewItems contain the items displayed in the hierarchy. |
TreeViewItem | Represents an item within a TreeView. The Header attribute or sub-element determines the content displayed for the item. |
UserControl | A container that you can use to create a simple compound control. Note, however, that classes derived from UserControl do not support templates. |
Window | Represents a window, the WPF equivalent of a form. The Window includes two areas: the client area where you normally put controls and the non-client area where the window displays borders, title bar, caption, system menus, and so on. Normally, you add a Window to an application by using the Project menu’s Add New Item command. |
For more detailed descriptions plus examples using these and other controls, see the Microsoft online help. You can find a reference for System.Windows.Controls classes at msdn2.microsoft.com/library/ system.windows.controls.aspx. You can find a reference for the System.Windows.Controls.Primatives classes, which include base classes used by other controls, at msdn2.microsoft.com/library/ system.windows.controls.primitives.aspx.