Hi,
Hopefully a quick question:
With the calendar control there is a SelectedDate property which allows me to get/set a date to be highlighted/selected. However i need to highlight/select a daterange from code. There is a selectedDates property, which allows you to get a List<DateTime> of selected dates, however i need to set this. Is there a way to do this?
Many thanks,
Hopefully a quick question:
With the calendar control there is a SelectedDate property which allows me to get/set a date to be highlighted/selected. However i need to highlight/select a daterange from code. There is a selectedDates property, which allows you to get a List<DateTime> of selected dates, however i need to set this. Is there a way to do this?
Many thanks,
6 Answers, 1 is accepted
0

Rick Glos
Top achievements
Rank 1
answered on 03 Jun 2010, 07:51 PM
I'm interested in the answer to this as well. According to the documentation, this is bindable - see here.
Although it is exposed as a list, you can bind it and... |
But when attempting to use it you get an error.
'SelectedDates' property is read-only and cannot be set from markup. |
Or if you try and set in code you get an error.
// Property or indexer 'Telerik.Windows.Controls.RadCalendar.SelectedDates' cannot be assigned to -- it is read only |
radCalendar1.SelectedDates = new List<DateTime>(); |
0

Toby
Top achievements
Rank 1
answered on 04 Jun 2010, 12:04 PM
Your link to the documentation got me thinking. I tried the following as a work around:
It would be helpful to be able to directly bind to a list, or set the list directly, however this should achieve the same thing.
private void setDate(DateTime from, DateTime to) |
{ |
//clear selection |
dateRangeCalendar.SelectedDate = null; |
//loop through range |
DateTime dateToAdd = from; |
while (dateToAdd <= to) |
{ |
//add to selection |
dateRangeCalendar.SelectedDates.Add(dateToAdd); |
dateToAdd = dateToAdd.AddDays(1); |
} |
} |
It would be helpful to be able to directly bind to a list, or set the list directly, however this should achieve the same thing.
0

Rick Glos
Top achievements
Rank 1
answered on 04 Jun 2010, 03:06 PM
Interesting, I didn't think to use the methods hanging off the IList. This would certainly give us a work-around. Although like you, I was hoping to bind this directly to my ViewModel. It would involve a bit of code hanging off the event handlers on the control to keep this list updated in both directions.
Telerik, can you tell us was this an oversight, making this property ReadOnly or done purposely? It would help us determine a course of action.
0
Accepted
Hello Rick Glos,
As you have noticed the property has a readonly accessor. You need to use the Add() method in order to add dates. We will consider adding an ItemsSource property that can be used with MVVM pattern.
Best wishes,
Kaloyan
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.
As you have noticed the property has a readonly accessor. You need to use the Add() method in order to add dates. We will consider adding an ItemsSource property that can be used with MVVM pattern.
Best wishes,
Kaloyan
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

Robert
Top achievements
Rank 1
answered on 18 Jan 2011, 01:19 PM
Hello Everybody,
Any news about ItemsSource property in RadCalendar ?
Any news about ItemsSource property in RadCalendar ?
0
Hello Toby,
There is no such a property exposed by the RadCalendar yet. You can create an attached property that will add a new selected date into the calendar itself and use it as a binding target. Let us know if you need any further explanation.
Kind regards,
Kaloyan
the Telerik team
There is no such a property exposed by the RadCalendar yet. You can create an attached property that will add a new selected date into the calendar itself and use it as a binding target. Let us know if you need any further explanation.
Kind regards,
Kaloyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>