Use “real” CultureInfo.CurrentCulture in WPF Binding, not CultureInfo from IetfLanguageTag

前端 未结 9 871
余生分开走
余生分开走 2020-11-29 05:19

In my case:

I have a TextBlock Binding to a property of type DateTime. I want it to be displayed as the Regional settings of the User says.



        
9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 05:33

    The problem that is avoiding using "this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);" is not really a common one. I don't know any user here in france that will change the date format to US or Japan one, just because at least no user is knowing that such a change is possible (and dont know how to do it)... So of course the "language=" is not perfect, but in many many years of WPF and Silverlight practice I never see a problem of this kind with any user... So I still use the "Langage=" trick, it is simple and cover 100% of real needs. Of course others solutions seem to be better, but there is no need for (and I saw a few implementations that are far from perfect compare to "language=" solution).

提交回复
热议问题