WPF XAML StringFormat DateTime: Output in wrong culture?

前端 未结 6 1472
南旧
南旧 2021-02-03 16:49

I\'m having some trouble with the output of a DateTime value. My computer\'s current culture is set to de-AT (Austria).

The following code

string s1 = Da         


        
6条回答
  •  臣服心动
    2021-02-03 17:42

    I Know that this is an aging question but this has always worked for me and sharing knowledge is a good thing. Since my apps always change language on the fly, the FrameworkElement.LanguageProperty.OverrideMetadata only works once and its no good for me, so behold:

    this.Language = System.Windows.Markup.XmlLanguage.GetLanguage(ActiveLanguage.CultureInfo.IetfLanguageTag);
    

    where (this) is the MainWindow, actually you have to do it in all rootelements (Windows). There you go simple enough.

提交回复
热议问题