Mahmoud Samy
Mahmoud Samy

Reputation: 439

How i can change language textbox in wpf?

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 ?

Upvotes: 5

Views: 4720

Answers (1)

apomene
apomene

Reputation: 14389

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...

Upvotes: 5

Related Questions