DockPanel Layout
Dock children to the edges in declaration order; the last child fills the rest.
Overview
DockPanel is the fastest way to build the classic shell: a header, a status
bar, a sidebar, and a content area that takes whatever is left. Each child claims one edge
of a rectangle that shrinks as it goes, so declaration order is the layout
— a Left child declared before a Top child runs the full height
of the panel, and the same two declared the other way round give the header the full width.
Sizes are whole cells. A docked child is measured from its own preferred size along the dock axis and clamped to what actually remains, so a header asking for ten rows in a four-row panel gets four rather than pushing its siblings out of the panel. Once the rectangle is empty the remaining children collapse to zero and are skipped.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| LastChildFill | bool | True | The last non-collapsed child fills the leftover rectangle. This is what spends the final cells. |
| DockPanel.Dock | Dock | Left | Attached. Left, Top, Right or Bottom. |
| Background | Color? | null | Inherited from Panel. |
Key Concepts
- Declaration order is the layout — each child docks against what is left, not against the panel
Left/Rightchildren take the full remaining height;Top/Bottomtake the full remaining widthLastChildFill(defaultTrue) hands the remainder to the last non-collapsed child, so no cell is left unassigned- A child larger than what remains is clamped, never allowed to overflow the panel
Visibility="Collapsed"gives up its cells entirely and siblings close the gap;Hiddenkeeps its allocation and paints as background