Holidays in UWP Gantt Chart

18 Nov 20181 minute to read

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

The holidays can be specified in a task using the Holidays property, 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.DataContext>      
         <local:ProjectTrackerViewModel/>        
   </gantt:SfGantt.DataContext>
</gantt:SfGantt>
SfGantt sfGantt = new SfGantt();

ProjectTrackerViewModel projectTrackerViewModel = new ProjectTrackerViewModel();

sfGantt.ItemsSource = projectTrackerViewModel.TaskCollection;

sfGantt.ShowNonWorkingDays = true;

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

this.Content = sfGantt;

Holidays

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