Version

We recommend that you use the xamDataGrid control instead of the xamGrid control. The xamGrid is being planned for retirement over the next few years and will not receive any new features. We will continue to provide support and critical bug fixes for the xamGrid during this time. For help or questions on migrating your codebase to the xamDataGrid, please contact support.

Set the Text Alignment on Column Headers

You can set the alignment of the Column header’s text by setting the HeaderTextHorizontalAlignment and HeaderTextVerticalAlignment properties. You can set these properties on the xamGrid control, the Column, or the ColumnLayout.

Setting the property on the Column takes precedence over setting the property on the ColumnLayout.

Setting the property on the ColumnLayout takes precedence over setting the property on xamGrid.

The Column and the ColumnLayout have two additional properties:

These two read-only properties are used to validate the actual value for a particular ColumnLayout or Column.

Note
Note:

The ColumnLayout and Column’s HeaderTextHorizontalAlignment and HeaderTextVerticalAlignment are nullable enums, therefore there will not be any intellisense for them in XAML. However, xamGrid’s HeaderTextHorizontalAlignment and HeaderTextVerticalAlignment properties are not nullable and will therefore have intellisense.

In XAML:

<ig:XamGrid x:Name="MyDataGrid" ItemsSource="{Binding Source={StaticResource DataUtil}, Path=CategoriesAndProducts}"
            AutoGenerateColumns="False" HeaderTextHorizontalAlignment="Right">
   <ig:XamGrid.Columns>
      <ig:TextColumn Key="CategoryID"/>
      <ig:TextColumn Key="CategoryName" HeaderTextHorizontalAlignment="Left" />
   </ig:XamGrid.Columns>
</ig:XamGrid>

In Visual Basic:

MyDataGrid.HeaderTextHorizontalAlignment = HorizontalAlignment.Right
MyDataGrid.Columns.DataColumns("CategoryName").HeaderTextHorizontalAlignment = HorizontalAlignment.Left

In C#:

MyDataGrid.HeaderTextHorizontalAlignment = HorizontalAlignment.Right;
MyDataGrid.Columns.DataColumns["CategoryName"].HeaderTextHorizontalAlignment = HorizontalAlignment.Left;
xamWebGrid Set Column Text Alignment 01.png