LearningThings
LearningThings

Reputation: 79

How do I center a grid column title in xaml?

I am trying to center the column titles of a grid in xaml (using Xamarin framework). I have the following line of code:

<dg:DataGridColumn Title="Name" PropertyName="TName" Width="1.2*" HorizontalContentAlignment="Center" CellTextMargin="10,0,0,0"/>

This centers the column text, but not the title. How can I fix this?

Edit: this is specifically for the grid control from the NuGet package Plugin.Controls.DataGrid v. 0.1.2

Upvotes: 1

Views: 407

Answers (2)

LearningThings
LearningThings

Reputation: 79

The solution was to set HorizontalHeaderAlignment="Center".

Upvotes: 1

pinedax
pinedax

Reputation: 9356

HorizontalContentAlignment="Center" as you have it should do the work but Center is already the default alignment Option for the Column Titles meaning that if you do not specify anything it will be centered (by default).

You can see this in the source code here. One of the beauty of OSS.

Remove the whole HorizontalContentAlignment from the Column.

Hope this helps.-

Upvotes: 0

Related Questions