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 应用程序中全局设置文化?
基础教程推荐
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
