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

Control.HorizontalContentAlignment Property

Gets or sets the horizontal 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 HorizontalAlignment HorizontalContentAlignment { get; set; }
/** @property */
public HorizontalAlignment get_HorizontalContentAlignment ()

/** @property */
public void set_HorizontalContentAlignment (HorizontalAlignment value)

public function get HorizontalContentAlignment () : HorizontalAlignment

public function set HorizontalContentAlignment (value : HorizontalAlignment)

<object HorizontalContentAlignment="HorizontalAlignment" .../>

Property Value

The horizontal alignment of a control's content. The default is Left.

NoteNote:

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

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

The following example shows how to set the horizontal content alignment property of a control.

<Button Name="btn7" 
        HorizontalContentAlignment="Left"
        Click="ChangeHorizontalContentAlignment">
  HorizontalContentAlignment
</Button>

void ChangeHorizontalContentAlignment(object sender, RoutedEventArgs e)
{
    if (btn7.HorizontalContentAlignment == HorizontalAlignment.Left)
    {
        btn7.HorizontalContentAlignment = HorizontalAlignment.Right;
        btn7.Content = "Control horizontal alignment changes from left to right.";

    }
    else
    {
        btn7.HorizontalContentAlignment = HorizontalAlignment.Left;
        btn7.Content = "HorizontalContentAlignment";
    }
}

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

Show:
© 2014 Microsoft