WPF XAML StringFormat DateTime: Output in wrong culture?
c#, datetime, wpf, xaml
Solution
Please see my answer on StringFomat Localization problem
Problem
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 = DateTime.Now.ToString("d"); string s2 = string.Format("{0:d}", DateTime.Now); ``` results in s1 and s2 both having the correct value of "30.06.2009". But when using the same format in XAML ``` <TextBlock Text="{Binding Source={x:Static sys:DateTime.Now}, StringFormat=d}"/> ``` the output is `"6/30/2009". It seems the XAML StringFormat ignores the current culture settings. This happens on both Vista and XP. I don't want to specify a custom format, because the output should be formatted in the user's preferred culture setting. Anybody with the same problem? Is this a bug in WPF?