How can i globally set the Culture in a WPF Application?(如何在 WPF 应用程序中全局设置文化?)
问题描述
我想根据用户偏好将 WPF 应用程序的文化设置为特定的.
I would like to set the Culture of a WPF application to a specific one based on user preferences.
我可以通过 Thread.CurrentThread.Current(UI)Culture
为当前线程执行此操作,但有没有办法为应用程序全局执行此操作(因此默认情况下它会影响所有线程)?
I can do this for the current thread via Thread.CurrentThread.Current(UI)Culture
, but is there any way to do this globally for the application (so it affects all threads by default)?
推荐答案
没有办法为应用程序中的所有线程设置它,但是如果您在应用程序中创建线程,您可以自己为每个人设置文化正如你上面提到的
there is no way to set it for all threads in the application, however if you are creating the threads in your application you can set the culture for everyone by yourself as you mentioned above
要将 Culture 设置为 Main Application,请使用以下代码段:
To set the Culture to the Main Application use the following snippet code:
Dim newCulture As CultureInfo = new CultureInfo("fr-FR")
CurrentThread.CurrentCulture = newCulture
这篇关于如何在 WPF 应用程序中全局设置文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 WPF 应用程序中全局设置文化?


基础教程推荐
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01