Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing FlowDirection of a cell in Wpf's DataGrid

I Have a DataGrid with its FlowDirection set to "RightToLeft". Problem is when displaying negative numbers, the minus sign is shown on the opposite side. Setting the FlowDirection of the cell itself to "LeftToRight" fixes it, but then the left border of the cell moves to the right, so I have no border on the left, and a double border on the right. How can I fix this?

like image 490
visualstudiostud Avatar asked Nov 14 '10 13:11

visualstudiostud


1 Answers

You're gonna have to set FlowDirection on the TextBox rather than on the DataGridCell. If you're using a DataGridTextColumn then

<DataGridTextColumn ...>
    <DataGridTextColumn.ElementStyle>
        <Style TargetType="TextBlock">
            <Setter Property="FlowDirection" Value="LeftToRight" />
        </Style>
    </DataGridTextColumn.ElementStyle>
    <DataGridTextColumn.EditingElementStyle>
        <Style TargetType="TextBox">
            <Setter Property="FlowDirection" Value="LeftToRight" />
        </Style>
    </DataGridTextColumn.EditingElementStyle>
</DataGridTextColumn>
like image 134
Fredrik Hedblad Avatar answered Oct 16 '22 15:10

Fredrik Hedblad