tags:

views:

2172

answers:

4

Hi all,

I'm using WPF datagrid which is bundled in WPF toolkit... the problem is I'm not able to align some column data to center

Please help me guys

+3  A: 

It's hard to say without knowing specifics, but here's a DataGridTextColumn that is centered:

<wpf:DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True">
 <wpf:DataGridTextColumn.CellStyle>
  <Style>
   <Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/>
  </Style>
 </wpf:DataGridTextColumn.CellStyle>
</wpf:DataGridTextColumn>

HTH, Kent

Kent Boogaart
+1  A: 

Ok, I used the frameworkElement approach but there was a strange behavior when you try to highlight the row.

I've put another example of WPF Datagrid alignment in this thread!

Junior Mayhé
A: 

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

<Style TargetType="DataGridCell">
     <Style.Setters>
            <Setter Property="TextBlock.TextAlignment" Value="Right" />
     </Style.Setters>
</Style>
Mohammed A. Fadil
A: 

thanks it is works for me

Kiran