What can a DockPanel
do that a StackPanel
cannot? If anyone has an image of something that can be achieved with a StackPanel
, but not a DockPanel
, than that would be great.
Asked
Active
Viewed 4.2k times
58
1 Answers
95
Stack Panel: The StackPanel
, as the name implies, arranges content either horizontally or vertically. Vertical is the default, but this can be changed using the Orientation
property. Content is automatically stretched based on the orientation (see screenshot below), and this can be controlled by changing the HorizontalAlignment
or VerticalAlignment
properties.
Dock Panel: The DockPanel
is used to anchor elements to the edges of the container, and is a good choice to set up the overall structure of the application UI. Elements are docked using the DockPanel.Dock
attached property. The order that elements are docked determines the layout.

Barn Monkey
- 245
- 3
- 11

Dhaust
- 5,470
- 9
- 54
- 80
-
19A `StackPanel` will not constrain its children to the available size, whereas a `DockPanel` will size the last child to occupy all remaining space. [stackpanel-dockpanel-and-scrolling-items](http://blogs.msdn.com/b/marcelolr/archive/2009/06/09/stackpanel-dockpanel-and-scrolling-items.aspx) – mungflesh Jun 30 '15 at 12:58