I've got a TextBox bound to a nullable DateTime property.
I'm in Australia, so I want dates presented in the d/mm/yyyy format.
On my Windows 7 box, I can enter the date in d/mm format, and it's converted correctly (eg. 1/11 converts to November 1st, 13/1 converts to January 13th etc.)
On my Windows 8 box, the same input is interpreted as if it was in the US format, so 1/11 converts to January 11th, and 13/1 fails (since there is no 13th month).
Both computers are set to use the Australian formats, and I have this code in the Application.StartUp event:
FrameworkElement.LanguageProperty.OverrideMetadata(GetType(FrameworkElement), New FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)))
The Binding's StringFormat is set to d/MM/yyyy, and I've checked that this is correct by also binding a TextBlock to the same property that has its StringFormat set to D (the long date format, which gives values like 'Wednesday, 11 January, 2012').
Does anyone have any ideas?
Update: Further investigation (see comments below) reveals this seems to be an issue with the en-AU culture being different on Windows 8 compared to Windows 7, which means that it interprets dates like '1/11' in mm/dd format on Windows 8, whereas on Windows 7, it interprets them in dd/mm format, which is what I'd expect when using the en-AU culture.
xml:lang="en-AU"
on the parent Window, settingConverterCulture=en-AU
on the Binding. Neither worked... (there isn't a converter on the Binding, but I figured I'd try it anyway) – AzoDateTime.Parse("1/11", CultureInfo.GetCultureInfo("en-AU")).Month
gives 11 on Windows 7, but 1 on Windows 8 - this isn't a WPF bug any more... – Azo1
. So its not confined to Win8. – Rohde