DockPanel
DockPanel is useful for
describing the overall layout of a simple user interface. You can carve
up the basic structure of your window using a DockPanel, and then use the other panels to
manage the details.
A DockPanel arranges each child
element so that it fills a particular edge of the panel. If multiple
children are docked to the same edge, they simply stack up against that
edge in order. By default, the final child fills any remaining space not
occupied by controls docked to the panel's edges.
Example 3-4 shows a simple DockPanel-based layout. Five buttons have been
added to illustrate each option. Notice that four of them have a
DockPanel.Dock attribute applied.
This property is defined by DockPanel
to allow elements inside a DockPanel
to specify their position. DockPanel.Dock is an attached property (as described in the
upcoming sidebar, "Attached Properties and Layout").
Example 3-4. Simple DockPanel layout
<DockPanel><ButtonDockPanel.Dock="Top">Top</Button> <ButtonDockPanel.Dock="Bottom">Bottom</Button> <ButtonDockPanel.Dock="Left">Left</Button> <ButtonDockPanel.Dock="Right">Right</Button> <Button>Fill</Button></DockPanel>