Text alignment in a WPF DataGrid

Prashant Cholachagudda picture Prashant Cholachagudda · Apr 6, 2009 · Viewed 72.6k times · Source

How can I align the column data to center in a WPF DataGrid?

Answer

Mohammed A. Fadil picture Mohammed A. Fadil · Apr 28, 2010

If you are using DataGridTextColumn you can use the following code snippet:

<Style TargetType="DataGridCell">
     <Style.Setters>
            <Setter Property="TextBlock.TextAlignment" Value="Center" />
     </Style.Setters>
</Style>