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

Special slots in TimelineView

6 Answers 74 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Håkan
Top achievements
Rank 1
Håkan asked on 24 Oct 2011, 12:37 PM
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

6 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 25 Oct 2011, 02:05 PM
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 >>

0
Håkan
Top achievements
Rank 1
answered on 26 Oct 2011, 01:52 PM
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



0
Rosi
Telerik team
answered on 27 Oct 2011, 10:52 AM
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 >>

0
Håkan
Top achievements
Rank 1
answered on 28 Nov 2011, 03:24 PM
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
0
Accepted
Rosi
Telerik team
answered on 29 Nov 2011, 09:41 AM
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 >>

0
Håkan
Top achievements
Rank 1
answered on 29 Nov 2011, 10:18 AM
Thanks Rosi!

Now it works for me.

Regards,
Håkan
Tags
ScheduleView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Håkan
Top achievements
Rank 1
Share this question
or