Expand Minimize
This topic has not yet been rated - Rate this topic

VerticalAlignment Enumeration

Describes how a child element is vertically positioned or stretched within a parent's layout slot.

Namespace:  System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)
[LocalizabilityAttribute(LocalizationCategory::None, Readability = Readability::Unreadable)]
public enum class VerticalAlignment
<object property="enumerationMemberName" .../>
Member nameDescription
BottomThe child element is aligned to the bottom of the parent's layout slot.
CenterThe child element is aligned to the center of the parent's layout slot.
StretchThe child element stretches to fill the parent's layout slot.
TopThe child element is aligned to the top of the parent's layout slot.

Height and Width properties that are explicitly set on an element take precedence over the Stretch property value.

The following example demonstrates how to use the VerticalAlignment enumeration in code and Extensible Application Markup Language (XAML).

No code example is currently available or this language may not be supported.
<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>

.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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.