Developing Arabic WPF applications – Part 3
I talked before about changing the input language in a textbox in Windows Forms but what about WPF? In WPF, you should use the InputLanguageManager class. You can use it in either the code or in the XAML markup. I wrote a sample to demo an application with default language set to Arabic(Egypt).
<Window x:Class="WpfApplication1.Window1" xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" InputLanguageManager.InputLanguage="ar-EG" Title="Input Language Change" Height="300" Width="300"> <Grid> <StackPanel Name="stackPanel1"> <TextBox InputLanguageManager.InputLanguage="en-US" InputLanguageManager.RestoreInputLanguage="True" Name="textBox1" Margin="10,4,10,10"/> <TextBox Name="textBox2" Margin="10,4,10,10" /> <TextBox Name="textBox3" Margin="10,4,10,10"/> </StackPanel> </Grid> </Window> |
TextBox2 is set to English input by default while the rest of the textboxes default to Arabic. Notice to return back to the default input you need to set InputLanguageManager.RestoreInputLanguage="True" , since the default is “False”.
Notice, you need to make sure that the keyboard already exists in your OS.
Comments
Anonymous
September 29, 2008
PingBack from http://www.simplynetdev.com/developing-arabic-wpf-applications-%e2%80%93-part-3/Anonymous
October 05, 2008
You have a typo, I think you mean "TextBox1 is set to English..." not TextBox2.Anonymous
February 06, 2009
RestoreInputLanguage: Exactly what I was looking for. Thanks.Anonymous
March 31, 2011
Link to part 4 blogs.msdn.com/.../developing-arabic-wpf-applications-part-4.aspx