如何更改 wpf 中的语言文本框?

How i can change language textbox in wpf?(如何更改 wpf 中的语言文本框?)
本文介绍了如何更改 wpf 中的语言文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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);

我不知道如何更改语言的问题因为代码在 WPF 中不起作用.

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 ?

推荐答案

为了完成你必须使用 InputLanguageManager 类

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

这篇关于如何更改 wpf 中的语言文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)