Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Scheduler > Change background of a day

Not answered Change background of a day

Feed from this thread
  • John avatar

    Posted on Jan 3, 2012 (permalink)

    I'm in week mode, and I need to iterate through all visible days, and change them a color of a background depending of a date.

    I'm using 2010 Q2 SP1

    Is it possible?

    Best regards,

    John

    Reply

  • Dani Dani admin's avatar

    Posted on Jan 3, 2012 (permalink)

    Hello John,

    You can do that with the TimeSlotTemplateSelector. Remember, this is a content template selector, so you would actually be setting background to content, rather than style to the time slot.

    I do suggest that you consider using RadScheduleView control instead of RadScheduler, because of the customization flexibility it offers. In RadScheduleView, what you need is easily achievable with the SpecialSlotStyleSelector.

    I hope this helps.

    Greetings,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • John avatar

    Posted on Jan 4, 2012 (permalink)

    Thank you Dani for your reply.

    I've added to my XAML:
    <DataTemplate x:Key="CurrentDaySlotTemplate">
        <Border Background="Red"/>
    </DataTemplate>
    <DataTemplate x:Key="NotCurrentDaySlotTemplate">
        <Border Background="Pink" />
    </DataTemplate>
     
    <local:TimeSlotTemplateSelector x:Key="TimeSlotTemplateSelector"
                                     CurrentDaySlotTemplate="{StaticResource CurrentDaySlotTemplate}"
                                     NotCurrentDaySlotTemplate="{StaticResource NotCurrentDaySlotTemplate}" />

    and my TimeSlotTemplateSelector is

    public class TimeSlotTemplateSelector : DataTemplateSelector
        {
            public DataTemplate CurrentDaySlotTemplate { get; set; }
            public DataTemplate NotCurrentDaySlotTemplate { get; set; }
     
            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                TimeSlot slot = item as TimeSlot;
                if (slot.ParentView.Scheduler != null)
                {
                    if (slot.ParentView.Scheduler.ViewMode == SchedulerViewMode.Week)
                    {
                        if (slot.Start.Date == DateTime.Now.Date)
                        {
                            return this.CurrentDaySlotTemplate;
                        }
                        else
                        {
                            return this.NotCurrentDaySlotTemplate;
                        }
     
                    }
                    
                }
                return this.NotCurrentDaySlotTemplate;
            }
        }

    but a result is as in the printscreen. It's not what I want.

    1. All day have the same background color , but I need to have a different color for current day.
    2. Only part of a day has setted color. I don't know why:/

    I have next question:
    Are there would be any problem with changing my RadScheduler to RadSchedulerView ? RadScheduler  is old , and not used, isn't it?

    Best regards,

    John
    Attached files

    Reply

  • Dani Dani admin's avatar

    Posted on Jan 6, 2012 (permalink)

    Hello John,

    Using your code I created a sample and I think the behavior you wish to achieve is exactly reproduced. Please, find attached a screenshot of the result I got.

    I suppose that the appearance you get is a result of some other customizations upon the control. Can you please share any other customizations you have applied? A working sample would be helpful.

    If you decide to switch to using RadScheduleView, there are resources you can use along the process. For example, the Migration from RadScheduler document which outlines main differences. Also, you can always count on uour support team to assist you during the migration.


    Regards,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Scheduler > Change background of a day
Related resources for "Change background of a day"

Silverlight Scheduler Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]