Developing Arabic WPF applications – Part 1
I’ll talk today about developing Arabic applications in Windows Presentation Foundation (WPF). The main property for right-to-left display is FlowDirection. FlowDirection is similar to the Windows Forms RightToLeft, but not exactly the same. FlowDirection simply sets the direction and the layout of the control. This includes setting the alignment to the right and the reading order to RTL, in addition, the whole layout of the control flows from the right side to the left.
When you set FlowDirection=RightToLeft of the control. You set the FlowDirection of the child controls, provided that you didn’t set it locally.
For example
<Window x:Class="WPFApp.Window1"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" FlowDirection="RightToLeft">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>
<Button>Button</Button>
<TextBlock Grid.Column="1"> Hello </TextBlock>
</Grid>
</Window>
Setting FlowDirection=”RightToLeft” would mean that the, first grid column is on the right-side, while the second-column is on the left –side and the Button and Text block also inherits the same FlowDirection.
So this means, that if you need to develop an RTL application,
1) You need to set FlowDirection very early in the design of your pages.
2) Design your LTR application (for example English) and after you finish the UI design, set FlowDirection and localize your application.
Note: Why am I saying this? because I met with an MVP , who was annoyed that we rearranges the items in the opposite direction when he set FlowDirection=RightToLeft. His case was simple, he started to design his Arabic form and then he realized that some full stops are appearing in the wrong direction (because of the ltr reading). So, he set the RTL property and was puzzled by the flipping that happened. In conclusion, remember to set the FlowDirection property from the start, as soon as you need to develop Arabic applications
On any case, I can talk a lot about WPF and Arabic support. So keep an eye on the next parts of this topic J
Comments
Anonymous
March 31, 2011
Link to part 2: blogs.msdn.com/.../developing-arabic-wpf-applications-part-2.aspxAnonymous
January 20, 2013
Thanks for the great Idea ... Input Language changes are gud whenever i type in textbox. but it should be vice versa right. Once i type in textbox im saving the arabic record in db. in db it displays some format (some unicode characters). when i retrive , i need to bind the textbox as arabic which ever i stored. How to bind Arabic value for single textbox not for the application