--- title: "How to: Create a StackPanel" ms.date: "03/30/2017" helpviewer_keywords: - "StackPanel control [WPF], creating" ms.assetid: e7ce65cb-720a-4bb6-95b6-286b74488a58 --- # How to: Create a StackPanel This example shows how to create a . ## Example A allows you to stack elements in a specified direction. By using properties that are defined on , content can flow both vertically, which is the default setting, or horizontally. The following example vertically stacks five controls, each with a different and , by using . The child elements that have no specified stretch to fill the parent window; however, the child elements that have a specified , are centered within the window. The default stack direction in a is vertical. To control content flow in a , use the property. You can control horizontal alignment by using the property. ```xaml Stacked Item #1 Stacked Item #2 Stacked Item #3 Stacked Item #4 Stacked Item #5 ``` ## See also - - [Panels Overview](panels-overview.md) - [How-to Topics](stackpanel-how-to-topics.md)