New to Telerik UI for WPF? Download free 30-day trial

Special Slots

RadGanttView provides SpecialSlotsGenerator property which can be used to mark certain intervals along the visible range of the control as special slots.

SpecialSlotsGenerator is of type IRangeGenerator and can be set to any of the following types:

We will go through each of them separately.

SingleRangeGenerator

SingleRangeGenerator applies a single special slot to the whole visible range of RadGanttView. It can be set like this:

<telerik:RadGanttView x:Name="ganttView" TasksSource="{Binding Tasks}" > 
    <telerik:RadGanttView.SpecialSlotsGenerator> 
        <telerik:SingleRangeGenerator /> 
    </telerik:RadGanttView.SpecialSlotsGenerator> 
</telerik:RadGanttView> 

And here is the end result:

ganttview specialslots 1

WeekDaysGenerator

WeekDaysGenerator allows you to set special slots on certain week days. It provides two properties:

  • FirstDay;

  • DaysCount.

So it can be used to mark the working days, for example:

<telerik:RadGanttView x:Name="ganttView1" TasksSource="{Binding Tasks}" > 
    <telerik:RadGanttView.SpecialSlotsGenerator> 
        <telerik:WeekDaysGenerator FirstDay="Monday" DaysCount="5" /> 
    </telerik:RadGanttView.SpecialSlotsGenerator> 
</telerik:RadGanttView> 

ganttview specialslots 2

Custom IRangeGenerator

You just need to create a custom class which implements IRangeGenerator interface and implement GetRanges method which receives as a parameter the current VisibleRange of the GanttView:

public class CustomRangeGenerator : ViewModelBase, IRangeGenerator 
{ 
    public System.Collections.Generic.IEnumerable<IDateRange> GetRanges(IDateRange visibleRange) 
    { 
        for (DateTime current = visibleRange.Start; current < visibleRange.End; current += TimeSpan.FromDays(1)) 
        { 
            int addDays = (int)current.DayOfWeek; 
            if (addDays < 7 && (int)current.DayOfWeek % 2 != 0) 
            { 
                yield return new DateRange(current, current.AddDays(1)); 
                addDays = addDays + 1; 
            } 
        } 
    } 
} 

Set the newly created class to the SpecialSlotsGenerator property:

<telerik:RadGanttView x:Name="ganttView2" TasksSource="{Binding Tasks}" > 
    <telerik:RadGanttView.SpecialSlotsGenerator> 
        <local:CustomRangeGenerator /> 
    </telerik:RadGanttView.SpecialSlotsGenerator> 
</telerik:RadGanttView> 

And the result is the following:

ganttview specialslots 3

You can check the GanttView Special Slots example at UI for WPF demos.

In this article