如何在 WPF 应用程序中全局设置文化?

How can i globally set the Culture in a WPF Application?(如何在 WPF 应用程序中全局设置文化?)
本文介绍了如何在 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 应用程序中全局设置文化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

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子句?)