Skip to main content
.NET Framework Class Library
ControlVerticalContentAlignment Property

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

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax
<[%$TOPIC/ms592525_en-us_VS_110_1_0_0_0_0%](True)> _
Public Property VerticalContentAlignment As [%$TOPIC/ms592525_en-us_VS_110_1_0_0_0_1%]
[[%$TOPIC/ms592525_en-us_VS_110_1_0_1_0_0%](true)]
public [%$TOPIC/ms592525_en-us_VS_110_1_0_1_0_1%] VerticalContentAlignment { get; set; }
[[%$TOPIC/ms592525_en-us_VS_110_1_0_2_0_0%](true)]
public:
property [%$TOPIC/ms592525_en-us_VS_110_1_0_2_0_1%] VerticalContentAlignment {
	[%$TOPIC/ms592525_en-us_VS_110_1_0_2_0_2%] get ();
	void set ([%$TOPIC/ms592525_en-us_VS_110_1_0_2_0_3%] value);
}
[<[%$TOPIC/ms592525_en-us_VS_110_1_0_3_0_0%](true)>]
member VerticalContentAlignment : [%$TOPIC/ms592525_en-us_VS_110_1_0_3_0_1%] with get, set
function get VerticalContentAlignment () : [%$TOPIC/ms592525_en-us_VS_110_1_0_4_0_0%] 
function set VerticalContentAlignment (value : [%$TOPIC/ms592525_en-us_VS_110_1_0_4_0_1%])
<object VerticalContentAlignment="[%$TOPIC/ms592525_en-us_VS_110_1_0_5_0_0%]" .../>

Property Value

Type: System.WindowsVerticalAlignment
One of the VerticalAlignment values. The default is VerticalAlignmentTop.
Dependency Property Information

Identifier field

VerticalContentAlignmentProperty

Metadata properties set to true

None

Remarks

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.

This property only affects a control whose template uses the VerticalContentAlignment property as a parameter. On other controls, this property has no impact.

Examples

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>
Private Sub ChangeVerticalContentAlignment(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    If (btn8.VerticalContentAlignment = VerticalAlignment.Top) Then

        btn8.VerticalContentAlignment = VerticalAlignment.Bottom
        btn8.Content = "Control vertical alignment changes from top to bottom." 

    Else

        btn8.VerticalContentAlignment = VerticalAlignment.Top
        btn8.Content = "VerticalContentAlignment" 
    End If 
End Sub
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";
    }
}
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1