right align columns

Sep 16, 2008 at 1:02 PM

How do you change the text alignment in each column in the datagrid?  I have some numeric fields that need to be right aligned.  The code below makes the data right aligned, but the right side starts in the center.  For example, the data looks like this:

|    5,555       |
|       555       | 

It needs to be like this:
|            5,555|
|               555| 

Any ideas?

<Style x:Key="tb_ElementStyle" TargetType="TextBlock">
    <Setter Property="TextAlignment" Value="Right" />
    <Setter Property="HorizontalAlignment" Value="Right" />
</Style>

<dg:DataGridTextColumn Width="130" 
    Header="First Name" 
    DataFieldBinding="{Binding Path=FirstName}" 
    ElementStyle="{StaticResource tb_ElementStyle}" />

Coordinator
Sep 17, 2008 at 12:41 PM
Are you using a template column with more than just a TextBlock?  I'm unable to repro your issue.
Sep 17, 2008 at 3:37 PM

I figured out my problem.  User error.  I'm so sorry.