How do you right align int and decimal columns

Jan 27, 2009 at 6:27 PM

How do you right align numeric columns?

Thanks

 

Jan 28, 2009 at 7:36 AM
Hi,

Try applying the following style to your column's CellStyle property:

<Style x:Key="RightAlignCell" TargetType="{x:Type dg:DataGridCell}" >
    <Setter Property="HorizontalAlignment" Value="Right"/>
</Style>

Regards,
Colin E.
--
http://www.scottlogic.co.uk/blog/wpf/ - my WPF blog
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx - WPF DataGrid Practical Examples



Jan 29, 2009 at 5:16 AM

Hi,

Thank you for ColinEber's suggestion, I try to apply the style to CellStyle and I found that if I change the Value to Center, datagrid will be display incorrectly.
So I modified you example as follow and it works for me

<Style x:Key="RightAlignCell" TargetType="{x:Type toolkit:DataGridCell}" >

Setter Property="TextBlock.TextAlignment" Value="Right"/>
</Style>

Regargs,

Watanyu Y.