* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.5 KiB
title, description, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | description | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| How to: Horizontally or Vertically Align Content in a StackPanel | Learn how to adjust content orientation in a Windows Presentation Foundation StackPanel and the HorizontalAlignment and VerticalAlignment of child content. | 03/30/2017 |
|
|
c1e8f962-72c8-4e7a-8670-7a2d7e021791 |
How to: Horizontally or Vertically Align Content in a StackPanel
This example shows how to adjust the xref:System.Windows.Controls.StackPanel.Orientation%2A of content within a xref:System.Windows.Controls.StackPanel element, and also how to adjust the xref:System.Windows.FrameworkElement.HorizontalAlignment%2A and xref:System.Windows.FrameworkElement.VerticalAlignment%2A of child content.
Example
The following example creates three xref:System.Windows.Controls.ListBox elements in [!INCLUDETLA#tla_xaml]. Each xref:System.Windows.Controls.ListBox represents the possible values of the xref:System.Windows.Controls.StackPanel.Orientation%2A, xref:System.Windows.FrameworkElement.HorizontalAlignment%2A, and xref:System.Windows.FrameworkElement.VerticalAlignment%2A properties of a xref:System.Windows.Controls.StackPanel. When a user selects a value in any of the xref:System.Windows.Controls.ListBox elements, the associated property of the xref:System.Windows.Controls.StackPanel and its child xref:System.Windows.Controls.Button elements change.
[!code-xamlStackPanelIntroSamp#1]
The following code-behind file defines the changes to the events that are associated with the xref:System.Windows.Controls.ListBox selection changes. xref:System.Windows.Controls.StackPanel is identified by the xref:System.Windows.FrameworkElement.Name%2A sp1.
[!code-csharpStackPanelIntroSamp#2] [!code-vbStackPanelIntroSamp#2]