Create Special Slots in Telerik ScheduleView for WPF

by XAML Team | Comments 5

With the new SP1 release of Q3 2010 we added a new feature to RadScheduleView that helps you customize every slot in a different way.custom slots

To do that you should create an instance of the Slot class, set its Start and  End  properties,


the Resources property - with this property you can define in which resource column the slot will be displayed,

and the RecurrencePattern property - with this property you can define whether the slot will be displayed for repeating days or events like Christmas, WeekendDays  and Birthdays.


For example let's say that we have a schedule control and want to customize the days that are holidays.

To do that we create slots for Christmas, Saint Valentine and Halloween days:
var christmasSlot = new Slot() { Start = new DateTime(2010, 12, 25), End = new DateTime(2010, 12, 26) };
            christmasSlot.RecurrencePattern = new RecurrencePattern();
            christmasSlot.RecurrencePattern.Interval = 1;
            christmasSlot.RecurrencePattern.Frequency = RecurrenceFrequency.Yearly;
            christmasSlot.RecurrencePattern.DayOfMonth = 25;
            christmasSlot.RecurrencePattern.MonthOfYear = 12;
            SpecialSlots.Add(christmasSlot);
 
            var valentineSlot = new Slot() { Start = new DateTime(2010, 2, 14), End = new DateTime(2010, 2, 15) };
            valentineSlot.RecurrencePattern = new RecurrencePattern();
            valentineSlot.RecurrencePattern.Interval = 1;
            valentineSlot.RecurrencePattern.Frequency = RecurrenceFrequency.Yearly;
            valentineSlot.RecurrencePattern.DayOfMonth = 14;
            valentineSlot.RecurrencePattern.MonthOfYear = 2;
            SpecialSlots.Add(valentineSlot);

When we are ready we should add the slots to the SpecialSlotsSource property of the control.

 The only thing left is to assign a style for Christmas, Halloween and St.Valentine. RadScheduleView has SpecialSlotsStyleSelector property that we will use for this task:

<telerik:RadScheduleView Grid.Column="1" Grid.Row="0"
                             x:Name="scheduleView"
                             SpecialSlotsSource="{Binding SpecialSlots}"
                             AppointmentsSource="{Binding Appointments}"
                             SpecialSlotStyleSelector="{StaticResource HolidayStyleSelector}"
                             Margin="10 0 10 0">
        <telerik:RadScheduleView.ViewDefinitions>
            <telerik:MonthViewDefinition />
        </telerik:RadScheduleView.ViewDefinitions>
    </telerik:RadScheduleView>

 You can now download the full project here , see another example using special slots in our online demos and start customizing the slots in your own unique way.

Rossitza Fakalieva
Team Lead,
Telerik XAML Team

5 Comments

Martin
Thanks Rosi F,

it was a good example.
I have a question. When I select 25 Dec, the TimeSlot become highlighted and the customTimeSlot is changed. (The background is not red colored and image disappears)

How to avoid that? Is there a way to set DataTemplateSelector for selected TimeSlots?


Regards, Martin
Rosi F

Hi Martin,

You can use the SelectionHighlightStyle property of the control to change the style of the selection. Note, that this will change the style for all selected slots. At this stage RadScheduleView does not support an option for changing the style of selection per slot.



Regards,

Rosi F.

Patrick
Hi,
I'm doing some test with the control, and when I create some SpecialSlot...it is possible to affect them to only specific resource?
Thanks
Patrick
Hi,
I'm doing some test with the control, and when I create some SpecialSlot...it is possible to affect them to only specific resource?
Thanks
Trevor
How do you apply the special slot to a single resouce?  For example, if I have employees, and I want to create a special slot to show unavailable times.   Adding the resources to the Resource collection of the slot does nothing.

Comments

  1.    
      
      
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)
Read more articles by XAML Team - or - read latest articles in Developer Tools