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.
VerticalAlignment Enumeration
.NET Framework 3.0
Describes how a child element is vertically positioned or stretched within a parent's layout slot.
Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] public enum VerticalAlignment
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ public enum VerticalAlignment
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) public enum VerticalAlignment
<object property="EnumerationValue" .../>
| Member name | Description | |
|---|---|---|
| Bottom | The child element is aligned to the bottom of the parent's layout slot. | |
| Center | The child element is aligned to the center of the parent's layout slot. | |
| Stretch | The child element stretches to fill the parent's layout slot. | |
| Top | The child element is aligned to the top of the parent's layout slot. |
The following example demonstrates how to use the VerticalAlignment enumeration in code and Extensible Application Markup Language (XAML).
TextBlock myTextBlock = new TextBlock(); myTextBlock.FontSize = 18; myTextBlock.HorizontalAlignment = HorizontalAlignment.Center; myTextBlock.Text = "VerticalAlignment Sample"; Grid.SetRow(myTextBlock, 0); Button myButton1 = new Button(); myButton1.VerticalAlignment = VerticalAlignment.Top; myButton1.Content = "Button 1 (Top)"; Grid.SetRow(myButton1, 1); Button myButton2 = new Button(); myButton2.VerticalAlignment = VerticalAlignment.Bottom; myButton2.Content = "Button 2 (Bottom)"; Grid.SetRow(myButton2, 2); Button myButton3 = new Button(); myButton3.VerticalAlignment = VerticalAlignment.Center; myButton3.Content = "Button 3 (Center)"; Grid.SetRow(myButton3, 3); Button myButton4 = new Button(); myButton4.VerticalAlignment = VerticalAlignment.Stretch; myButton4.Content = "Button 4 (Stretch)"; Grid.SetRow(myButton4, 4);
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowTitle="VerticalAlignment Sample"> <Border Background="LightBlue" BorderBrush="Black" BorderThickness="2" Padding="15"> <Grid Background="White" ShowGridLines="True"> <Grid.RowDefinitions> <RowDefinition Height="25"/> <RowDefinition Height="50"/> <RowDefinition Height="50"/> <RowDefinition Height="50"/> <RowDefinition Height="50"/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" FontSize="18" HorizontalAlignment="Center">VerticalAlignment Sample</TextBlock> <Button Grid.Row="1" Grid.Column="0" VerticalAlignment="Top">Button 1 (Top)</Button> <Button Grid.Row="2" Grid.Column="0" VerticalAlignment="Bottom">Button 2 (Bottom)</Button> <Button Grid.Row="3" Grid.Column="0" VerticalAlignment="Center">Button 3 (Center)</Button> <Button Grid.Row="4" Grid.Column="0" VerticalAlignment="Stretch">Button 4 (Stretch)</Button> </Grid> </Border> </Page>
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
Show: