DayButtonStyleSelector not working

2 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 16 Oct 2012 Link to this post


    I messed around a lot with the Calendar but I can't get it working with DayButtonStyleSelector.

    I created a new project, added a StyleSelector class and tried to use it -- SelectStyle is never called.
    My XAML:
    <Window x:Class="WpfApplication1.MainWindow"
            Title="MainWindow" Height="350" Width="525" xmlns:telerik="">
                <VMs:MyStyleSelector x:Key="stsWeekend">
                        <Style TargetType="{x:Type calendar:CalendarButton}">
                            <Setter Property="Background">
                                    <SolidColorBrush Color="Orange" Opacity="0.6"/>
            <telerik:RadCalendar HorizontalAlignment="Left" Margin="68,96,0,0" Name="radCalendar1" VerticalAlignment="Top" DayButtonStyleSelector="{StaticResource stsWeekend}"/>

    My Style selector Class:
    namespace WpfApplication1 {
        public class MyStyleSelector : System.Windows.Controls.StyleSelector {
            public override Style SelectStyle(object item, DependencyObject container) {
                CalendarButtonContent content = item as CalendarButtonContent;
                if(content != null) {
                    if(content.Date.DayOfWeek == DayOfWeek.Tuesday && content.ButtonType == CalendarButtonType.Date) {
                        return SpecialStyle;
                return base.SelectStyle(item, container);
            public Style SpecialStyle { get; set; }

    I use 2012.2.1015.40

  2. Yana
    Yana avatar
    4547 posts

    Posted 19 Oct 2012 Link to this post

    Hello Manfred,

    You should also add DayButtonStyle="{x:Null}" to the Calendar definition in order to apply the Selector correctly:

    <telerik:RadCalendar HorizontalAlignment="Left" Margin="68,96,0,0"
                            Name="radCalendar1" VerticalAlignment="Top"
                            DayButtonStyleSelector="{StaticResource stsWeekend}"/>

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
Back to Top