Export (0) Print
Expand All

Control.VerticalContentAlignment Property

Gets or sets the vertical alignment of a control's content.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[BindableAttribute(true)] 
public VerticalAlignment VerticalContentAlignment { get; set; }
/** @property */
public VerticalAlignment get_VerticalContentAlignment ()

/** @property */
public void set_VerticalContentAlignment (VerticalAlignment value)

public function get VerticalContentAlignment () : VerticalAlignment

public function set VerticalContentAlignment (value : VerticalAlignment)

<object VerticalContentAlignment="VerticalAlignment" .../>

Property Value

The vertical alignment of a control's content. The default value is Top.

NoteNote:

 In addition to Top, Bottom, and Center, you can set the VerticalContentAlignment property to Stretch, which stretches the child element to fill the allocated layout space of the parent element. For more information, see Alignment, Margins, and Padding Overview.

Also, the template of a control that inherits the VerticalContentAlignment property can affect the content layout.

The following example shows how to set the vertical content alignment property on a control.

<Button Name="btn8" Height="50"
        VerticalContentAlignment="Top" 
        Click="ChangeVerticalContentAlignment">
  VerticalContentAlignment
</Button>

void ChangeVerticalContentAlignment(object sender, RoutedEventArgs e)
{
    if (btn8.VerticalContentAlignment == VerticalAlignment.Top)
    {
        btn8.VerticalContentAlignment = VerticalAlignment.Bottom;
        btn8.Content = "Control vertical alignment changes from top to bottom.";

    }
    else
    {
        btn8.VerticalContentAlignment = VerticalAlignment.Top;
        btn8.Content = "VerticalContentAlignment";
    }
}

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.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft