Chapter 6. Layout Controls

Layout controls are primarily intended to contain and arrange other controls. They position the controls they contain in different ways to make it easier to design various kinds of user interfaces.

Layout controls are not quite the same as container controls. While all layout controls do contain other controls, the converse is not true: Not all controls that contain other controls arrange those controls in a nontrivial way.

For example, the GroupBox control draws a header and a border around a single child. Because its main purpose is to draw the header and border and because it contains only a single child control, it doesn't really do much arranging.

These non-arranging container controls are described elsewhere. For example, the GroupBox is described in the previous chapter.

Control Overview

The following table briefly lists the controls described in this chapter together with their purposes. You can use this table to help decide which control you need in a particular situation.

Control

Purpose

Canvas

Lets you position child controls explicitly by specifying the distances between their left, top, right, and bottom edges and those of the Canvas.

DockPanel

Docks its children to its edges.

Expander

Displays a header and an icon that the user can click on to show or hide a single child control.

Grid

Displays children in rows and columns. You can also ignore the rows and columns and position children somewhat as you can in a Canvas.

ScrollViewer

Displays a single child in ...

Get WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 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.