简体   繁体   中英

change textbox input language on change of app language

I am working on a metro app which provides a change language option in app. I want that on change of language textbox input language also get change. and it should not depends on system language.

首先,您需要确保要在OS中安装所需的语言,并且该语言在“已安装的输入语言”列表中(请检查“语言和区域设置”下控制面板中的语言栏)。如果未在语言栏中显示,添加它..例如,您要将应用程序语言更改为“法语” ..您需要为要在应用程序中更改的每种语言创建一个新的资源文件,然后更改当前线程的文化属性。.您熟悉吗资源文件(.resx)和文化信息类?

I use these codes: First of all you must find the name of the culture language you want. method "GetInutLanguageByName" will return the language that you requested Then you will check whether you installed the requested language or not, if yes then return the requested language. Then change the input language very easy...

private static InputLanguage GetInutLanguageByName(string layOut)
    {
        foreach (InputLanguage lng in InputLanguage.InstalledInputLanguages)
        {
            if (lng.Culture.DisplayName == layOut)
            {
                return lng;
            }
        }
        return null;

    }

private void SetKeyboardLayout(InputLanguage Layout)
    {
        InputLanguage.CurrentInputLanguage = Layout;
    }

private void FirstNameTextBox_Enter(object sender, EventArgs e)
    {

        SetKeyboardLayout(GetInutLanguageByName("Persian"));

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM