Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WrapPanel.Orientation Property

Gets or sets a value that specifies the dimension in which child content is arranged.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
'Declaration
Public Property Orientation As Orientation
<object Orientation="Orientation" .../>

Property Value

Type: System.Windows.Controls.Orientation
An Orientation value that represents the physical orientation of content within the WrapPanel as horizontal or vertical. The default value is Horizontal.

Identifier field

OrientationProperty

Metadata properties set to true

AffectsMeasure

If the Orientation property is set to Horizontal, child content forms horizontal rows first and if necessary forms vertical stacks of rows. If the Orientation property is set to Vertical, child content is first positioned in a vertical column, and if there is not enough space, wrapping occurs and additional columns in the horizontal dimension are added.

The following example demonstrates how to set the Orientation property in Extensible Application Markup Language (XAML).

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="WrapPanel Properties Sample">
  <Border HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="2">
        <WrapPanel Orientation="Horizontal" Background="Azure" ItemWidth="25" ItemHeight="25" Height="200" Width="200">
            <Button Width="200">Button 1</Button>
            <Button>Button 2</Button>
            <Button>Button 3</Button>
        </WrapPanel>
  </Border>    
</Page>

The following example demonstrates how to set the Orientation property by using code.

            WindowTitle = "WrapPanel Sample" 

            ' Instantiate a new WrapPanel and set properties 
            Dim myWrapPanel As New WrapPanel()
            myWrapPanel.Background = Brushes.Azure
            myWrapPanel.Orientation = Orientation.Horizontal

            myWrapPanel.Width = 200
            myWrapPanel.HorizontalAlignment = Windows.HorizontalAlignment.Left
            myWrapPanel.VerticalAlignment = Windows.VerticalAlignment.Top

            ' Define 3 button elements. The last three buttons are sized at width  
            ' of 75, so the forth button wraps to the next line. 
            Dim btn1 As New Button()
            btn1.Content = "Button 1"
            btn1.Width = 200
            Dim btn2 As New Button()
            btn2.Content = "Button 2"
            btn2.Width = 75
            Dim btn3 As New Button()
            btn3.Content = "Button 3"
            btn3.Width = 75
            Dim btn4 As New Button()
            btn4.Content = "Button 4"
            btn4.Width = 75

            ' Add the buttons to the parent WrapPanel using the Children.Add method.
            myWrapPanel.Children.Add(btn1)
            myWrapPanel.Children.Add(btn2)
            myWrapPanel.Children.Add(btn3)
            myWrapPanel.Children.Add(btn4)

            ' Add the WrapPanel to the Page as Content 
            Me.Content = myWrapPanel
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" WindowTitle="WrapPanel Sample">
  <Border HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="2">
        <WrapPanel Background="LightBlue" Width="200" Height="100">
            <Button Width="200">Button 1</Button>
            <Button>Button 2</Button>
            <Button>Button 3</Button>
            <Button>Button 4</Button>
        </WrapPanel>
  </Border>    
</Page>

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft. All rights reserved.