This question is locked. New answers and comments are not allowed.
Hi,
I want to control the calendar display month, not by user swipe but by "previous" & "next" buttons. So I made a page with a calendar & 2 butons.
To do this, I use the following method:
// Set for the start of this month..
DateTime calendarDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
.....
private void displayCalendar() {
radCalendar.DisplayDateStart = calendarDate;
// Calculate the end month
DateTime endDate = calendarDate;
endDate = endDate.AddMonths(1);
//endDate = endDate.AddDays(-1); // This is the end of the month
radCalendar.DisplayDateEnd = endDate;
Then I have this event:
private void buttonCalendarPrevious_Click(object sender, RoutedEventArgs e)
{
calendarDate = calendarDate.AddMonths(-1);
displayCalendar();
}
But this is not working. I get the error ArgumentOutOfRange {"Invalid DisplayDateEnd value.\r\nParameter name: sender"}
I checked the dates, and checked them again. They are correct, Start is 01/04/2012. End is 01/05/2012.
Maybe I do something wrong here. But it seems I cannot set the range again after initializing the calendar.
How can I manage the display of the calendar and flip months using code ?
Thanks,
Steven
I want to control the calendar display month, not by user swipe but by "previous" & "next" buttons. So I made a page with a calendar & 2 butons.
To do this, I use the following method:
// Set for the start of this month..
DateTime calendarDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
.....
private void displayCalendar() {
radCalendar.DisplayDateStart = calendarDate;
// Calculate the end month
DateTime endDate = calendarDate;
endDate = endDate.AddMonths(1);
//endDate = endDate.AddDays(-1); // This is the end of the month
radCalendar.DisplayDateEnd = endDate;
}
The first time I use this code I get the month of "May" displayed. No problem. It works. But.....Then I have this event:
private void buttonCalendarPrevious_Click(object sender, RoutedEventArgs e)
{
calendarDate = calendarDate.AddMonths(-1);
displayCalendar();
}
But this is not working. I get the error ArgumentOutOfRange {"Invalid DisplayDateEnd value.\r\nParameter name: sender"}
I checked the dates, and checked them again. They are correct, Start is 01/04/2012. End is 01/05/2012.
Maybe I do something wrong here. But it seems I cannot set the range again after initializing the calendar.
How can I manage the display of the calendar and flip months using code ?
Thanks,
Steven