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"




    Title="Input Language Change"  Height="300" Width="300">


        <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"/>






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 (4)

  1. Mohamed says:

    You have a typo,

    I think you mean "TextBox1 is set to English…" not TextBox2.

  2. Stan says:

    RestoreInputLanguage:  Exactly what I was looking for.  Thanks.

Skip to main content