DateTime Not showing with currentculture format in Datagrid,ListView

Viewed 8497

In WPF I am trying to Bind a date property in a DataGrid and I can only sort if it's bound to a DateTime property.

The application should show the date in a format corresponding to the user's Region and Language settings.

The issue is that when the date is a string property, it shows according to the Region settings, but when the property is bound to a DateTime the date format defaults to American rather than the correct region.

So if it's bound to a string property the sorting by column doesn't work, and if it's bound to a DateTime property, it doesn't convert to the correct region.

3 Answers

The other answer (overriding Language metadata) worked for me, but only once for a run of the application. A second call would fail. I replaced it with:

var wpfLanguage = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.IetfLanguageTag);
Application.Current.MainWindow.Language = wpfLanguage;
Related