Special slots in TimelineView

7 posts, 1 answers
  1. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 24 Oct 2011 Link to this post

    Hi,

    I use SpecialSlots to show saturdays with a blue background and sundays with a red background.
    That works in Month and Day view. But in my horizontal TimelineView set to VisibleDays = 7 the background does not change at all.

    Regards,
    Håkan
  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 25 Oct 2011 Link to this post

    Hi Håkan,

    This is a very strange behavior. Is it possible to send us sample running project or the StyleSelector that you use to test it locally?

    Greetings,
    Rosi
    the Telerik team

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

  3. DevCraft banner
  4. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 26 Oct 2011 Link to this post

    Hi Rosi.

    I can't send you a project since it is part of a huge application, but I can send you some bits and pieces.
    Tell me if you need more.

    public class CustomSpecialSlotStyleSelector : ScheduleViewStyleSelector
    {
        public Style DefaultStyle { get; set; }
        public Style ReadOnlyStyle { get; set; }
        public Style SaturdayStyle { get; set; }
        public Style SundayStyle { get; set; }
     
        public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDefinition)
        {
            if (item is DefaultOccurence)
                return this.DefaultStyle;
            else if (item is ReadOnlyOccurence)
                return this.ReadOnlyStyle;
            else if (item is SundayOccurence)
                return this.SundayStyle;
            else if (item is SaturdayOccurence)
                return this.SaturdayStyle;
            return base.SelectStyle(item, container, activeViewDefinition);
        }
    }
     
    public class DefaultOccurence : Slot
    {
        public override Slot Copy()
        {
            return new DefaultOccurence()
            {
                Start = this.Start,
                End = this.End,
                RecurrencePattern = this.RecurrencePattern.Copy()
            };
        }
    }
     
    public class ReadOnlyOccurence : Slot
    {
        public override Slot Copy()
        {
            return new ReadOnlyOccurence()
            {
                Start = this.Start,
                End = this.End,
                IsReadOnly = true,
                RecurrencePattern = this.RecurrencePattern.Copy()
            };
        }
    }
     
    public class SaturdayOccurence : Slot
    {
        public override Slot Copy()
        {
            return new SaturdayOccurence()
            {
                Start = this.Start,
                End = this.End,
                RecurrencePattern = this.RecurrencePattern.Copy()
            };
        }
    }
     
    public class SundayOccurence : Slot
    {
        public override Slot Copy()
        {
            return new SundayOccurence()
            {
                Start = this.Start,
                End = this.End,
                RecurrencePattern = this.RecurrencePattern.Copy()
            };
        }
    }

    <local:CustomSpecialSlotStyleSelector x:Key="CustomSpecialSlotStyleSelector">
        <local:CustomSpecialSlotStyleSelector.DefaultStyle>
            <Style TargetType="telerik:HighlightItem">
                <Setter Property="Margin" Value="0,-37,0,0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="{x:Null}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </local:CustomSpecialSlotStyleSelector.DefaultStyle>
        <local:CustomSpecialSlotStyleSelector.ReadOnlyStyle>
            <Style TargetType="telerik:HighlightItem">
                <Setter Property="Margin" Value="0,-37,0,0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="{x:Null}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </local:CustomSpecialSlotStyleSelector.ReadOnlyStyle>
        <local:CustomSpecialSlotStyleSelector.SaturdayStyle>
            <Style TargetType="telerik:HighlightItem">
                <Setter Property="Margin" Value="0,-37,0,0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="{StaticResource GradientLightBlue}" Opacity="0.2" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </local:CustomSpecialSlotStyleSelector.SaturdayStyle>
        <local:CustomSpecialSlotStyleSelector.SundayStyle>
            <Style TargetType="telerik:HighlightItem">
                <Setter Property="Margin" Value="0,-37,0,0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="{StaticResource GradientLightRed}" Opacity="0.2" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </local:CustomSpecialSlotStyleSelector.SundayStyle>
    </local:CustomSpecialSlotStyleSelector>

    private void SetupSpecialSlots()
    {
        ObservableCollection<Slot> specialSlots = new ObservableCollection<Slot>();
     
        DateTime start = new DateTime(DateTime.Today.Year, 1, 1, 0, 0, 0);
        DateTime end = new DateTime(DateTime.Today.Year, 1, 1, 23, 59, 59);
        bool readOnly = (displayMode == TimeSchedulePlanningDisplayMode.User);
     
        if (displayMode == TimeSchedulePlanningDisplayMode.User)
        {
            specialSlots.Add(new ReadOnlyOccurence()
            {
                Start = start,
                End = end,
                IsReadOnly = readOnly,
                RecurrencePattern = new RecurrencePattern(null, RecurrenceDays.EveryDay, RecurrenceFrequency.Daily, 1, null, null)
            });
        }
     
        specialSlots.Add(new SaturdayOccurence()
        {
            Start = start,
            End = end,
            IsReadOnly = readOnly,
            RecurrencePattern = new RecurrencePattern(null, RecurrenceDays.Saturday, RecurrenceFrequency.Weekly, 1, null, null)
        });
        specialSlots.Add(new SundayOccurence()
        {
            Start = start,
            End = end,
            IsReadOnly = readOnly,
            RecurrencePattern = new RecurrencePattern(null, RecurrenceDays.Sunday, RecurrenceFrequency.Weekly, 1, null, null)
        });
     
        ScheduleView.SpecialSlotsSource = specialSlots;
    }

    Regards,
    Håkan



  5. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 27 Oct 2011 Link to this post

    Hello Håkan,

    Please find attached sample project based on your code that works as expected. I suggest you try it and find the differences at your side.

    Greetings,
    Rosi
    the Telerik team

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

  6. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 28 Nov 2011 Link to this post

    Hello Rosi,

    Your project containd resources that are commented out in the constructor of the MainPage.
    I use resources, so I tried to uncomment your code, and then I get the same problem as in my project.

    Could you verify that on your side that you can use special slots in TimelineView with resource grouping?

    Regards,
    Håkan
  7. Answer
    Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 29 Nov 2011 Link to this post

    Hello Håkan,

    Please find attached updated project.To work everything as expected I changed the implementation of SaturdayOccurence and SundayOccurence classes.

    Greetings,
    Rosi
    the Telerik team

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

  8. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 29 Nov 2011 Link to this post

    Thanks Rosi!

    Now it works for me.

    Regards,
    Håkan
Back to Top
DevCraft banner