Stack Panel

The Stack Panel is a WPF control that is similar to a dock panel, except that it stacks its child controls in either a horizontal or vertical single line, depending on its orientation, in a defined area. Stack panels are not capable of wrapping their child controls. Controls are added to a stack panel in the same way as a dock panel.

By default, objects are stacked vertically. You can use the Orientation property to re-orient a stack panel.

Although the stack panel cannot anchor its child controls like the grid panel, you can emulate object anchoring for proper resizing. To do this, first set the Width and Height properties of the stack panel to Auto. As long as the stack panel is placed inside a root element with resizing capabilities—for example, a grid—the entire stack panel resizes with its root element. Then, depending on the orientation of the stack panel, change either the height (for horizontal orientation) or width (for vertical orientation) of the child control(s) to Auto. This anchors the objects to the edges of the stack panel and resizes the child objects when the root element is resized.

See Grids and Panels to view the usage and description of the properties for this control.