Syncing daytemplate selector with ObservableCollection (MVVM)

2 posts, 0 answers
  1. Thomas Garp
    Thomas Garp avatar
    11 posts
    Member since:
    Aug 2008

    Posted 04 Jun 2013 Link to this post

    Hi telerik support

    I have a changing observable list of dates on my viewmodel, and I would like to highlight the days within that collection.

    I have tried to implement my own DataTemplateSelector for the dayTemplateselector and I have managed to get the dates from my CollectionViewSource, but it seems that it only works on static data and the changes made to my collection does not appear in the Calendar.

    How can I archive binding between the daytemplateSelector and my observableCollection?

  2. Ivo
    Ivo avatar
    390 posts

    Posted 07 Jun 2013 Link to this post

    Hi Thomas,

    Changes made into your ObservableCollection are not affected into the RadCalendar because the SelectTemplate method into your custom DayTemplateSelector is called only while the control is being rendered. There is an easy way to workaround this however it is a little hacky. You can pass the RadCalendar control to your DayTemplateSelector and reset its template every time when the ObservableCollection changes. You can find attached a sample project that demonstrates this approach.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top