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

Bug with RadCalendar

9 Answers 113 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
NR
Top achievements
Rank 1
NR asked on 01 Oct 2010, 04:33 PM
I think there might be a slight bug with the RadCalendar and the "DisplayDateEnd" property.

I have a RadCalendar in my Silverlight Application.

I set the SelectedDate, SelectableDateEnd, and DisplayDateEnd all to DateTime.Today.AddDays(-1).

The problem seems to be with the DisplayDateEnd. I get the exception:
System.ArgumentOutOfRangeException: Invalid DisplayDateEnd value.
Parameter name: sender
   at Telerik.Windows.Controls.RadCalendar.OnDisplayDateEndChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
   at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.RadCalendar.set_DisplayDateEnd(Nullable`1 value)
   at STARv2.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

I believe this will only happen on the 1st of the month.. and possibly only for today.. so if you want to be able to test it out, I'd HIGHLY recommend doing it today. This code has been in my application for about 2 to 3 weeks without incident, then today I suddenly get this problem.

Please take a look at it ASAP in order to be able to properly diagnose it quickly.

9 Answers, 1 is accepted

Sort by
0
NR
Top achievements
Rank 1
answered on 01 Oct 2010, 09:23 PM
You can probably get the same problem on 10/2/2010 if you set the DisplayDateEnd = DateTime.Today.AddDays(-2)

It seems to be a problem with the control attempting to render an "empty" calendar. If you set the DisplayDateEnd to a date prior to the beginning of the month, because the RadCalendar seems to default the view to "Current Month" which would be empty, it throws an exception.
0
George
Telerik team
answered on 05 Oct 2010, 01:03 PM
Hello,

You could refer to the following topic in our online documentation - http://www.telerik.com/help/silverlight/radcalendar-constraining-selection-and-visible-dates.html. I would suggest you to check if the date you set is valid before you set it to the RadCalendar.

Please, let me know if this helps. I will be glad to assist you further.  

Kind regards,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
NR
Top achievements
Rank 1
answered on 05 Oct 2010, 04:08 PM
I can't see that as being true. It works for ANY other day other than the last day  of the previous month. If you look at the attachment in my support ticket, I subtract the days of the month to create "selectedDate" instead of adding 1 day to it before setting the DisplayDateEnd, move that line just under the initial declaration of selectedDate. You'll see that it works fine. I can set all 3 of those date parameters to the same exact date and it will work for every instance of it except for days in a previous month.

I believe this is a bug in the RadCalendar. Below is a code snippet I just ran from my RadCalendar Demo project I included in my support ticket... the DisplayDateEnd is well after the SelectedDate or SelectableDateEnd and it produces the same error.

This problem isn't due to a mysterious constraint on the dates. What I'm asking it to do is not abnormal.

DateTime selectedDate = DateTime.Today.AddDays(-DateTime.Today.Day);
selectedDate = selectedDate.AddDays(-10);
RadCalendar1.SelectedDate = selectedDate;
RadCalendar1.SelectableDateEnd = selectedDate;
selectedDate = selectedDate.AddDays(5);
// It will break on this line.
RadCalendar1.DisplayDateEnd = selectedDate;

So please look into this further. I do not honestly believe this is some user error on my part. If you set SelectedDate, SelectableDateEnd, and DisplayDateEnd all to DateTime.Today it will work... or even DateTime.Today.AddDays(-1).. the only problem is if you keep going back to the previous month... and I believe it is due to the calendar trying to draw "This month" and failing. Is there a way I can set the default date that is displayed on popup/load to be a different month?
0
George
Telerik team
answered on 06 Oct 2010, 04:50 PM
Hello,

If you are agree, I would suggest to continue the conversation in the support ticket . 

Sincerely yours,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Justin
Top achievements
Rank 1
answered on 18 Aug 2011, 01:59 AM
Was this ever resolved?  I am now having "almost" the exact same issue - however what I am doing is setting the display start/end and selectable start/end dates to only show the dates in current month.

To explain more what I am doing - I have a list of month names in a datagrid. Whenever user selects a different month I am resetting the calendar to display using the correct start and end dates.

For some reason this works fine when the control is first loading (shows the current month as expected), but if I change the month, and therefore the start and end dates, it errors out as mentioned in this thread...

So for first load it is being set as as 8/1/2011, and end as 8/31/2011. When the month view selection changes the date values are showing as expected (ie:, for May the DateTime values are 5/1/2011 and 5/31/2011).

I am at a loss as to what is going on here. 

Justin

0
Justin
Top achievements
Rank 1
answered on 18 Aug 2011, 07:18 PM
Disregard my last post.  I finally fixed this - what was happening is there was an odd loop in my code that was causing this to work every other time...

Sorry :)

Justin
0
Justin
Top achievements
Rank 1
answered on 18 Aug 2011, 09:31 PM
Actually - I still need help with this. I am not sure what happened - but I swear this was fixed when I left the office last night. And this morning it is not working again. I am not finding the behaviour consistent - sometimes it works and sometimes it does not...

Code below:
This code is called after selected item (of grid) is changed - which has the list of months.  So when you click on January the start date is 01/01/2011, and the end date is 01/31/2011

(selectedMonth.DaysInMonth is an int value with the last day of that month)

displayStart = new DateTime(tmpYear, tmpMonth, 1);
displayEnd = new DateTime(tmpYear, tmpMonth, selectedMonth.DaysInMonth);
 
calendar1.DisplayDate = displayStart.AddDays(1);
 
displayEnd = DateTime.Parse(displayEnd.ToShortDateString());
 
if (RadCalendar.IsDisplayDateStartValid(calendar1, displayStart))
{
    calendar1.DisplayDateStart = displayStart;
    calendar1.SelectableDateStart = displayStart;
}
 
if (RadCalendar.IsDisplayDateEndValid(calendar1, displayEnd))
{
    calendar1.DisplayDateEnd = displayEnd;
    calendar1.SelectableDateEnd = displayEnd;
}



Justin
0
Justin
Top achievements
Rank 1
answered on 22 Aug 2011, 09:50 PM
I have opened a support ticket with sample project (456565)

Justin
0
Yana
Telerik team
answered on 23 Aug 2011, 12:02 PM
Hi Justin,

We'll review the ticket. Thanks

Best wishes,
Yana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Calendar
Asked by
NR
Top achievements
Rank 1
Answers by
NR
Top achievements
Rank 1
George
Telerik team
Justin
Top achievements
Rank 1
Justin
Top achievements
Rank 1
Yana
Telerik team
Share this question
or