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

Calendar constrain only days, not months

1 Answer 23 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 31 Mar 2011, 07:50 PM
I setup a calender to only display months using the great examples given by Telerik at http://www.telerik.com/help/silverlight/radcalendar-selectors.html

my calendar only used Mondays.
public class WeekendingSelector : DataTemplateSelector
{
    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        CalendarButtonContent content = item as CalendarButtonContent;
        if (content != null)
        {
            if (content.Date.DayOfWeek != DayOfWeek.Monday)
            {
                content.IsEnabled = false;
            }
        }
        return DefaultTemplate;
    }
    public DataTemplate DefaultTemplate { get; set; }
}

The problem is when you jump out of the month view into the year view, every month that does not start on a Monday is disabled! Is there a fix for this? Maybe a work around?

1 Answer, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 06 Apr 2011, 08:29 AM
Hi Shawn,

You are missing an if condition. Follow the code bellow:
CalendarButtonContent content = item as CalendarButtonContent;
            if (content != null)
            {
                if (content.ButtonType == CalendarButtonType.Date && content.Date.DayOfWeek != DayOfWeek.Monday)
                {
                    content.IsEnabled = false;
                }
            }


All the best,
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
Tags
Calendar
Asked by
Shawn
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or