This is a migrated thread and some comments may be shown as answers.

[Solved] ArgumentOutOfRangeException when using MinValue

1 Answer 305 Views
TimePicker for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Erez
Top achievements
Rank 2
Erez asked on 20 May 2014, 07:45 PM
Hi,

I have two bindable properties in my view-model: DateBegin and DateEnd. Both are of type DateTime.

Using the RadTimePicker, if binding both MaxValue (DateEnd) and MinValue(DateBegin) I get the following exception: 

System.ArgumentOutOfRangeException: Hour, Minute, and Second parameters describe an un-representable DateTime.
   at System.DateTime.TimeToTicks(Int32 hour, Int32 minute, Int32 second)
   at System.DateTime..ctor(Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second)
   at Telerik.UI.Xaml.Controls.Input.DateTimePickers.DateTimeList.GetDateTimeAt(Int32 logicalIndex)
   at Telerik.UI.Xaml.Controls.Input.DateTimePickers.DateTimeList.IsItemEnabled(Int32 logicalIndex)
   at Telerik.UI.X

DateEnd = DateTime.Now
DateBegin = DateEnd.AddHours(-24)

If I set only either one of these properties, the control works without exception but will, of-course, default to a 6 hours window.

Is it a bug or am I doing something wrong?

Thank you,
Erez

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 23 May 2014, 08:33 AM
Hello Erez,

Thank you for contacting us.

Unfortunately, we could not reproduce this error on our side. I have attached a sample project that I made according to the described scenario and no exception is thrown. Could you please modify it to reproduce the error.

Another thing, the RadTimePicker control uses only the time part of the DateTime structure, this means that it sees the DateTime.Now and DateTime.Now.AddHours(-24) as the same time and this is why it won't allow the user to pick any time. I have commented the lines of code in the project that could fix your problem.

Please, let us know if this works for you.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TimePicker for XAML
Asked by
Erez
Top achievements
Rank 2
Answers by
Rosy Topchiyska
Telerik team
Share this question
or