Change StackPanel Orientation : StackPanel « Windows Presentation Foundation « VB.Net Tutorial






<Window x:Class="LayoutPanels.SimpleStack"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SimpleStack" Height="223" Width="354" MinWidth="50">
  <StackPanel Margin="3" Name="stackPanel1">
    <Label Margin="3" HorizontalAlignment="Center">
      A Button Stack
    </Label>
    <Button Margin="3" MaxWidth="200" MinWidth="100">Button 1</Button>
    <Button Margin="3" MaxWidth="200" MinWidth="100">Button 2</Button>
    <Button Margin="3" MaxWidth="200" MinWidth="100">Button 3</Button>
    <Button Margin="3" MaxWidth="200" MinWidth="100">Button 4</Button>

    <CheckBox Name="chkVertical" Margin="10" HorizontalAlignment="Center"
     Checked="chkVertical_Checked" Unchecked="chkVertical_Unchecked">
      Use Vertical Orientation</CheckBox>            
  </StackPanel>
</Window>



//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes

Namespace LayoutPanels
  Public Partial Class SimpleStack
    Inherits Window

    Public Sub New()
      InitializeComponent()
    End Sub

    Private Sub chkVertical_Checked(sender As Object, e As RoutedEventArgs)
      stackPanel1.Orientation = Orientation.Horizontal
    End Sub

    Private Sub chkVertical_Unchecked(sender As Object, e As RoutedEventArgs)
      stackPanel1.Orientation = Orientation.Vertical
    End Sub
  End Class
End Namespace
WPF Change Stack Panel Orientation








16.44.StackPanel
16.44.1.StackPanel with Button, Ellipse and ListBoxStackPanel with Button, Ellipse and ListBox
16.44.2.Set DataContext for StackPanelSet DataContext for StackPanel
16.44.3.Arrange UI Elements in a Horizontal or Vertical StackArrange UI Elements in a Horizontal or Vertical Stack
16.44.4.StackPanel with Image BackGroundStackPanel with Image BackGround
16.44.5.Vertical StackPanelVertical StackPanel
16.44.6.Horizontal StackPanelHorizontal StackPanel
16.44.7.Put buttons to StackPanelPut buttons to StackPanel
16.44.8.Focus scope for StackPanelFocus scope for StackPanel
16.44.9.Add Button and TextBox to StackPanelAdd Button and TextBox to StackPanel
16.44.10.Align left along StackPanelAlign left along StackPanel
16.44.11.StackPanel with MinHeight, MinWidth, VerticalAlignment, HorizontalAlignmentStackPanel with MinHeight, MinWidth, VerticalAlignment, HorizontalAlignment
16.44.12.StackPanel with Label and TextBoxStackPanel with Label and TextBox
16.44.13.StackPanel search layoutStackPanel search layout
16.44.14.Using StackPanel to group elements for absolute positioningUsing StackPanel to group elements for absolute positioning
16.44.15.Search for an element by using Panel.FindName()Search for an element by using Panel.FindName()
16.44.16.Change StackPanel OrientationChange StackPanel Orientation
16.44.17.Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel.Use the methods that are defined by the IScrollInfo interface to scroll the child content of a StackPanel.
16.44.18.Use StackPanel to arrange child objects in a single line that you can align horizontally or vertically.Use StackPanel to arrange child objects in a single line that you can align horizontally or vertically.