StackPanel.Orientation Property (System.Windows.Controls)

Switch View :
ScriptFree
.NET Framework Class Library for Silverlight
StackPanel.Orientation Property

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

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)
Syntax

Visual Basic (Declaration)
Public Property Orientation As Orientation
C#
public Orientation Orientation { get; set; }
XAML Attribute Usage
<StackPanel Orientation="Horizontal"/>
-or-
<StackPanel Orientation="Vertical"/>

Property Value

Type: System.Windows.Controls.Orientation
One of the enumeration values that specifies the orientation of child elements. The default is Vertical.
Remarks

Dependency property identifier field: OrientationProperty

Examples

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

XAML

<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" />
</StackPanel>


The preceding example produces output that is similar to the following illustration.

basic horizontal stack panel
Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources