Custom Slot class for special slot selector

3 posts, 1 answers
  1. Michael
    Michael avatar
    18 posts
    Member since:
    Aug 2010

    Posted 26 Jul 2011 Link to this post


    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,

  2. Answer
    Rosi avatar
    2529 posts

    Posted 29 Jul 2011 Link to this post

    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,
    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!

  3. Michael
    Michael avatar
    18 posts
    Member since:
    Aug 2010

    Posted 03 Aug 2011 Link to this post

    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,

Back to Top