How do you right align int and decimal columns

Jan 27, 2009 at 6:27 PM

How do you right align numeric columns?



Jan 28, 2009 at 7:36 AM

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"/>

Colin E.
-- - my WPF blog - WPF DataGrid Practical Examples

Jan 29, 2009 at 5:16 AM


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"/>


Watanyu Y.