Wrap Panel

The Wrap Panel is a WPF control that arranges child controls sequentially and linearly from left to right within a defined area and wraps (that is, breaks) to the next line when a control reaches the edge of the defined area.

As with a dock or stack panel, wrap panels have either a horizontal or vertical orientation, which is adjusted with their Orientation property, and adds controls from either the left or right side, depending upon their FlowDirection property. Controls are added to a wrap panel in the same manner as they are added to a dock panel.

The wrap panel’s ItemWidth and ItemHeight properties determine the child control’s size and layout. By default, these properties are set to Auto.

Since this panel automatically readjusts its child controls in the designer when it is resized, it is easy to visualize how this panel rearranges its contents when placed within a root element with resizing capabilities. For example, consider a wrap panel with horizontal orientation that contains three side-by-side buttons. When the panel is resized to where the edge of the third button meets the right side of the panel, the third button is automatically “wrapped” or shifted downward to the next line to accommodate the panel’s new size.

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