Calendar constrain only days, not months

2 posts, 1 answers
  1. Shawn
    Shawn avatar
    10 posts
    Member since:
    Mar 2011

    Posted 31 Mar 2011 Link to this post

    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?
  2. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 06 Apr 2011 Link to this post

    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
  3. DevCraft banner
Back to Top