#22 – Layout Controls

In WPF, the primary model for control layout is flow-based, rather than coordinate-based.  Child controls are added to a layout container control, which manages the location and size of the child controls based on the size and shape of the container.

Here are the main layout controls included in WPF:

  • Canvas – Coordinate-based layout container
  • DockPanel – Controls aligned against one edge of container (e.g. Top/Bottom/Left/Right/Fill)
  • Grid – Controls positioned in rows and columns.  (Default top-level control in empty WPF app)
  • StackPanel – Controls in horizontal or vertical stack
  • UniformGrid – Controls positioned in a grid where all cells have the same size
  • VirtualizingStackPanel – Arrange controls in horizontal or vertical stack.  Controls shown are a visible subset from larger list of items.  Loads controls as needed, i.e. as they become visible.
  • WrapPanel – Controls placed on single line, left-to-right, then wrap to next line if needed.  Can also be top-to-bottom, wrap to next column.

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: