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

本文标题为:如何在 WPF 应用程序中全局设置文化?

基础教程推荐