StackPanel.Orientation Property


Gets or sets the dimension by which child elements are stacked.

 property Orientation Orientation { Orientation get(); void set(Orientation value); };
Orientation Orientation();

void Orientation(Orientation value);
public Orientation Orientation { get; set; }
var orientation = stackPanel.orientation;
stackPanel.orientation = orientation;
Public Property Orientation As Orientation
<StackPanel Orientation="Horizontal"/>
<StackPanel Orientation="Vertical"/>

Property Value


One of the enumeration values that specifies the orientation of child elements. The default is Vertical.


The following example creates a horizontal list of items by setting the Orientation property to Horizontal.

<StackPanel Orientation="Horizontal" Margin="20">
    <Rectangle Fill="Red" Width="50" Height="50" Margin="5" />
    <Rectangle Fill="Blue" Width="50" Height="50" Margin="5" />
    <Rectangle Fill="Green" Width="50" Height="50" Margin="5" />
    <Rectangle Fill="Purple" Width="50" Height="50" Margin="5" />

Applies to