Red Calendar Day / Special Dates

2 posts, 0 answers
  1. thorsten wand
    thorsten wand avatar
    2 posts
    Member since:
    Sep 2009

    Posted 04 Sep 2009 Link to this post

    Hi,
    I have a question regarding red calendar days(special days). There are video tutorials for winforms and silverlight which use red calendar days. Unfortunately I couldn't find a collection of Special Days in the WPF RadCalendar Control property section in Visual Studio 2008.
    How can I bind a DateCollection as Special Days to the RadCalendar Control?

    Thanks in advance

    tWand
  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 08 Sep 2009 Link to this post

    Hi thorsten wand,

    The RadCalendar control is not exposing such a collection you can use to add some Special Days. To achieve scenario like the one above, you can use DayTemplateSelector property.
        <telerikInput:RadCalendar x:Name="calendar" IsTodayHighlighted="true" 
                                SelectionChanged="OnCalendarSelectionChanged" DayTemplate="{x:Null}" 
                                HorizontalAlignment="Center" VerticalAlignment="Center" 
                                SelectionMode="Extended" Columns="3" ViewsHeaderVisibility="Visible" 
                                Culture="en-US"
                            <telerikInput:RadCalendar.DayTemplateSelector>  
                                <my:DisableWeekendsSelection> 
                                    <my:DisableWeekendsSelection.DefaultTemplate>  
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding Text}" /> 
                                        </DataTemplate> 
                                    </my:DisableWeekendsSelection.DefaultTemplate> 
                                    <my:DisableWeekendsSelection.SpecialDay> 
                                        <DataTemplate> 
                                            <TextBlock Text="{Binding Text}" Foreground="Red"/> 
                                        </DataTemplate> 
                                    </my:DisableWeekendsSelection.SpecialDay> 
                                </my:DisableWeekendsSelection> 
                            </telerikInput:RadCalendar.DayTemplateSelector> 
                        </telerikInput:RadCalendar> 
     
    public class DisableWeekendsSelection : DataTemplateSelector 
        { 
            public override DataTemplate SelectTemplate(object item, DependencyObject container) 
            { 
                CalendarButtonContent content = item as CalendarButtonContent; 
     
                if (content != null
                { 
                    if (content.Date.DayOfWeek == DayOfWeek.Saturday || content.Date.DayOfWeek == DayOfWeek.Sunday) 
                    { 
                        content.IsEnabled = false
                    } 
                }  
                if (content.Date.Day % 11 == 0 && content.ButtonType == CalendarButtonType.Date) 
                { 
                    return SpecialDay; 
                } 
     
                return DefaultTemplate; 
            } 
     
            private DataTemplate defaultTemplate; 
            public DataTemplate DefaultTemplate 
            { 
                get 
                { 
                    return defaultTemplate; 
                } 
                set 
                { 
                    defaultTemplate = value; 
                } 
            } 
     
            private DataTemplate specialDay; 
            public DataTemplate SpecialDay 
            { 
                get 
                { 
                    return specialDay; 
                } 
                set 
                { 
                    this.specialDay = value; 
                } 
            } 
        } 
     
    All the best,
    Kaloyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top