This is a migrated thread and some comments may be shown as answers.

Custom Slot class for special slot selector

2 Answers 113 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 26 Jul 2011, 02:24 PM
Hi,

I want to derive from Telerik.Windows.Controls.ScheduleView.Slot to add some extra information as IsHoliday to my special slots and than use this in my special slot style selector. My scheduler binds to an ObservableCollection<CSchedulerSlot> as SpecialSlotsSource.
But the "object item" which is passed to SelectStyle method of the selector is always of type Slot instead of my custom class CSchedulerSlot. The following code does not work, becuase i always get a an InvalidCastException.

public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDefinition)
        {
            FrameworkElement elem = container as FrameworkElement;
 
            if (elem == null)
                return base.SelectStyle(item, container, activeViewDefinition);
           
            CSchedulerSlot slot = (CSchedulerSlot)item;

What I'm doing wrong? Is there a workaround for this?

thanks in advance,

michael

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 29 Jul 2011, 11:19 AM
Hi Michael,

I suggest you override the Copy and CopyFrom methods of the base Slot class as it is shown here. This should solve the problem.

Kind regards,
Rosi
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Michael
Top achievements
Rank 1
answered on 03 Aug 2011, 02:47 PM
Hi Rosi,

thanks for your answer. This solves my problem perfectly and I finally got rid of my static holiday checking in the style selector which makes my application cleaner and faster. :-)

best regards,

michael
Tags
ScheduleView
Asked by
Michael
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Michael
Top achievements
Rank 1
Share this question
or