The date time picker control crashes when using foreign culture settings in windows e.g. German, Finnish.
These cultures use date stamps like 22.10.2014 1:05:07, 100
Iff you dont provide a custom FormatString the control will display, but wont allow interaction and will throw an uncaught exception if you attempt to open the calendar.
Additionally iff you stipulate a FormatString in XAML the app will crash with an XAML exception.
I tracked this bug in V 2.3 to the following:
DateTimeUpDown.cs line 559 - DateTime date = DateTime.Parse(Value.ToString());
I am not sure why this is there, Value is already a DateTime? so you can easily check if its null and if not extract the date time directly without using parse (an absolute nightmare function btw). Also upstream the Value is checked for null so worrying about null SHOULDN'T be an issue, although this would choke on null anyways.
My fix was: DateTime date = Value.Value;
Would still break on null, but SHOULD be safe to assume thats not an issue.
Maybe I am just having weird issues, but seems to be a bug to me.
Hope this helps :D
Comments: ** Comment from web user: splintor **
These cultures use date stamps like 22.10.2014 1:05:07, 100
Iff you dont provide a custom FormatString the control will display, but wont allow interaction and will throw an uncaught exception if you attempt to open the calendar.
Additionally iff you stipulate a FormatString in XAML the app will crash with an XAML exception.
I tracked this bug in V 2.3 to the following:
DateTimeUpDown.cs line 559 - DateTime date = DateTime.Parse(Value.ToString());
I am not sure why this is there, Value is already a DateTime? so you can easily check if its null and if not extract the date time directly without using parse (an absolute nightmare function btw). Also upstream the Value is checked for null so worrying about null SHOULDN'T be an issue, although this would choke on null anyways.
My fix was: DateTime date = Value.Value;
Would still break on null, but SHOULD be safe to assume thats not an issue.
Maybe I am just having weird issues, but seems to be a bug to me.
Hope this helps :D
Comments: ** Comment from web user: splintor **
The problem still occurs in v2.3 (Community)
I didn't meant that it happens when you set the TimeFormatString. I meant that it happens when you go to Control Panel, select Region and Language, then click Additional settings and go to the Time tab and then change the Long time to be "hh-mm-ss tt".
Then, when you run the app in the above code, the Date Picker is displayed, but when you try to set its value (by selecting from the dropdown calendar, or by clicking the up or down buttons), you get an exception you cannot catch.
If you try to set the Value property to a value in XAML, the exception occur as the control is created.