Holidays

The holidays support is used to highlight the non-working days in the Gantt chart.

The holidays can be specified in a task using the Holidays property in the SfGantt, which holds a collection of GanttHoliday.

The following properties in the GanttHoliday are used to define the holidays:

  • Day: Specifies the holiday date.
  • Background: Specifies the color to highlight the holiday.

The following code sample demonstrates how to define the holidays.

<gantt:SfGantt ItemsSource="{Binding TaskCollection}" ShowNonWorkingDays="True" >
    <gantt:SfGantt.Holidays>
        <gantt:GanttHolidayCollection>
            <gantt:GanttHoliday Day="5/28/2018"
                                Background="CadetBlue" />
        </gantt:GanttHolidayCollection>
    </gantt:SfGantt.Holidays>
</gantt:SfGantt>
SfGantt sfGantt = new SfGantt();

sfGantt.ItemsSource = (this.DataContext as ProjectTrackerViewModel).TaskCollection;

sfGantt.ShowNonWorkingDays = True;

sfGantt.Holidays = new GanttHolidayCollection()
{
    new GanttHoliday()
    {
        Day = new DateTime(2018, 5, 28),
        Background = new SolidColorBrush(Colors.CadetBlue)
    }
};

Holidays

NOTE

To highlight the holidays in the Gantt chart, the ‘ShowNonWorkingDays’ property must be enabled.