問題描述
我想根據(jù)用戶偏好將 WPF 應(yīng)用程序的文化設(shè)置為特定的.
I would like to set the Culture of a WPF application to a specific one based on user preferences.
我可以通過 Thread.CurrentThread.Current(UI)Culture
為當(dāng)前線程執(zhí)行此操作,但有沒有辦法為應(yīng)用程序全局執(zhí)行此操作(因此默認(rèn)情況下它會影響所有線程)?
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)?
推薦答案
沒有辦法為應(yīng)用程序中的所有線程設(shè)置它,但是如果您在應(yīng)用程序中創(chuàng)建線程,您可以自己為每個人設(shè)置文化正如你上面提到的
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 設(shè)置為 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
這篇關(guān)于如何在 WPF 應(yīng)用程序中全局設(shè)置文化?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!