Hi Telerik,
I'm having trouble getting the calendar to reselect template for the calendarbuttoncontent after initial load.
I've found that if I "browse" the calendar (so that the content is not shown) and back again, the template is reapplied, using updated information in my behind lists of dates.
I have created the following template selector:
In XAML i bind to the selector as a static resource like this:
And my template selection is like this:
Now the question - How can I explicitly have the calendar redo its template selection, like it does when the content gets redrawn when "browsing" the calendar.
And what I would really want to do is to only redo the template selection on specific days if possible.
Thanks in advance!
Best regards,
Kasper Schou
I'm having trouble getting the calendar to reselect template for the calendarbuttoncontent after initial load.
I've found that if I "browse" the calendar (so that the content is not shown) and back again, the template is reapplied, using updated information in my behind lists of dates.
I have created the following template selector:
public class CalendarButtonTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; if (content != null && content.ButtonType == CalendarButtonType.Date) { if (CentralCalendarWindow.CalendarViewItems != null && CentralCalendarWindow.CalendarViewItems.Exists(c => c.Date == content.Date)) { CalendarViewItem calendarViewItem = CentralCalendarWindow.CalendarViewItems.Find(c => c.Date == content.Date); if (calendarViewItem.Holiday) { return HolidayTemplate; } else if (calendarViewItem.NoDistribution) { return NoDistributionTemplate; } else if (calendarViewItem.PartlyNoDistribution) { return PartlyNoDistributionTemplate; } } } return DefaultTemplate; } public DataTemplate DefaultTemplate { get; set; } public DataTemplate HolidayTemplate { get; set; } public DataTemplate NoDistributionTemplate { get; set; } public DataTemplate PartlyNoDistributionTemplate { get; set; } }In XAML i bind to the selector as a static resource like this:
DayTemplateSelector="{StaticResource templateSelector}"And my template selection is like this:
<this:CalendarButtonTemplateSelector x:Key="templateSelector" DefaultTemplate="{StaticResource dataTemplateDefault}" HolidayTemplate="{StaticResource dataTemplateHoliday}" NoDistributionTemplate="{StaticResource dataTemplateNoDistribution}" PartlyNoDistributionTemplate="{StaticResource dataTemplatePartlyNoDistribution}"/>Now the question - How can I explicitly have the calendar redo its template selection, like it does when the content gets redrawn when "browsing" the calendar.
And what I would really want to do is to only redo the template selection on specific days if possible.
Thanks in advance!
Best regards,
Kasper Schou