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

How to show selected date when using DayTemplateSelector

1 Answer 81 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Rodney Lane
Top achievements
Rank 1
Rodney Lane asked on 06 Feb 2014, 09:03 AM
Hi All

I have a WPF RadCalendar control where I use a DayTemplate Selector to present cells based on a lookup from a database.

The basic premise if that when particular conditions are met the cells will change colour or display different shapes and the like.

I have this working fine, but I have an issue where once the DayTemplateSelector has repainted the cells in the calendar, the Selected Day is no longer shown as selected. If I check the SelectedDate property of the calendar in my code behind, its correct - but the calendar is not displaying it.

If I click on that date again, the selected date is shown correctly.

Is there some way of forcing the calendar to show the selected date again after the calendar has finished rendering using the DayTemplateSelector?

I have tried setting the selectedDate to nothing then back to the correct date to see if that would trigger the selected date to be displayed, but it didn't. It seems to only show the selection when clicked from the UI.

Any thoughts or suggestions would be very much appreciated.

I am using 2012.RadControls_for_WPF_2012_2_0912_Dev_hotfix version of the Calendar control in DotNet 4.0 application.

Its using MVVM with Prism4, so everything is handles through bindings.

Cheers

Rod.

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 11 Feb 2014, 09:43 AM
Hello Rodney,

The SelectedDate is not visible because the Template from the DayTemplateSelector is applied on the top of the CalendarButton. However what you can do is to modify the ControlTemplate of the CalendarButton in order to include an additional border which will be used to indicate the SelectedDate by modifying its opacity in the Selected VisualState. For your convenience I have prepared a sample project which demonstrates the exact approach (check the CalendarButtonStyle in the merged resource dictionary). 

Hope this helps.

Regards,
Kalin
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
Calendar
Asked by
Rodney Lane
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or