I’ve been asked on how to change the keyboard layout when the application is loaded, e.g. when your localized application is starting up you need to set the keyboard layout to Persian (Farsi).

You may need a snippet like this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
private InputLanguage GetFarsiLanguage()
{
//Enumerate through InstalledInputLanguages which contains
//all the keyboard layout you’ve installed in your windows.
foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
{
if(lang.LayoutName.ToLower() == "farsi")
return lang;
}

return null;
}

public void YourMethod()
{
InputLanguage lang = GetFarsiLanguage();

if(lang == null)
throw new NotSupportedException("Farsi Language keyboard is not installed.");

//Set the current language of the system to
//the InputLanguage instance you need.
InputLanguage.CurrentInputLanguage = lang;
}