Dock Panel

The Dock Panel is a WPF control that arranges its child controls horizontally or vertically, relative to each other, in a defined area.

A dock panel’s children inherit an attached dependency property called Dock. This property appears in the object’s Properties panel after the object has been added to a dock panel. The Dock property determines whether the objects are placed above, below, to the left, or to the right of one another inside the dock panel, depending on how the Dock property is set for each child control. By default, an object’s Dock property is set to Left.

Note: A dock panel does not explicitly position objects in the same way as the canvas or grid controls. Controls cannot be drawn onto the dock panel or selected and moved; they can only be positioned in relation to another object.

The Dock panel has a unique property called LastChildFill. This property specifies whether the last object added to the Dock panel fills the remaining space.

By default, the LastChildFill property is enabled. When enabled, the last control added to the Dock panel automatically appears stretched in the remaining space of the dock panel, regardless of how the Dock property is set on the control. For the last control’s Dock property to work, the LastChildFill check box property on the Dock panel must be cleared.

If you want the control added to your dock panel to fill the remaining space or stretch within the dock panel, set the control’s Width and Height properties to Auto.

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