How i can change language textbox in wpf?

2020-03-04 08:09发布

问题:

I am new with WPF.

I'm trying to change the language within the text box when writing inside, In a window form i was using this code.

System.Globalization.CultureInfo TypeOfLanguage = new System.Globalization.CultureInfo("en-us");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(TypeOfLanguage);

The problem I do not know how I will be able to change the language Because the code does not work in WPF.

Please help me How i can change the input language ?

回答1:

In order to acomplish that you have to use InputLanguageManager Class

this.Dispatcher.Thread.CurrentCulture.Name.ToString();
InputLanguageManager.SetInputLanguage(myTextBox, CultureInfo.CreateSpecificCulture("fr"));
tb2.Text = "Available Input Languages:";
lb1.ItemsSource = InputLanguageManager.Current.AvailableInputLanguages;
tb3.Text = "Input Language of myTextBox is " + InputLanguageManager.GetInputLanguage(myTextBox).ToString();
tb4.Text = "CurrentCulture is Set to " + this.Dispatcher.Thread.CurrentCulture.Name.ToString();

Note: Code pasted form above link...



标签: c# wpf textbox