I am using a DatePicker in my WPF form, and am having the problem that when a user enters a date in British format, ie 31/12/1980, WPF seems to want to convert it to American, so it reads 12/31/1980.
This is giving me an out of range exception on my SQL insert.
Has anyone come across this before, and if so, how did you fix it?
You need to make sure that the UI has the correct locale set.
I’m not sure about WPF, but I know that in Silverlight there’s a bug whereby the XAML isn’t honouring the locale of Windows. You have to include the following code into the constructor of the view:
Now if your computer isn’t set to
en-GBbut your application requires this you’ll need to force the language either by setting theCurrentCultureof the application thread or passing in “en-GB”.