Search code examples
wpfvb.netxamldatagridwpf-controls

How to make RTL to support right to left languages only in a column in XAML WPF VB.NET


If using FlowDirection="RightToLeft" will change the whole datagrid right to left and solves the problem. But my grid has both LTR and RTL contents. Some columns are LTR and some other column are RTL. So please help me on this that how can I only set one column as RTL? Thanks.


Solution

  • At last I found the answer. Here it is:

    <DataGrid x:Name="DataGridR2L" FlowDirection="RightToLeft">
          <DataGrid.Columns>
               <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>
            </DataGrid.Columns>       
    </DataGrid>