Calendar Customization in WPF Gantt

31 Mar 20225 minutes to read

This feature allows you to set your own schedule for the entire project. Using this feature you can customize the calendar as per the organization’s requirement.

Use Case Scenarios

You can use this feature when you want to change the schedule as needed. For example, if April to March is your financial year, you can set this as your fiscal year and schedule the tasks accordingly.

You can also use this to schedule the works that have different week cycle. For example if your organization follows the week cycle from Wednesday to Tuesday, you can achieve this using calendar Customization feature.

Properties

Property Description Type Data Type Reference links
WeekBeginsOn Gets or sets the starting day of a week in the project schedule. By default it is set to Sunday. DependencyProperty Enum N/A
FiscalYearBeginsOn Gets or sets the starting month of a fiscal year. By default it is set to January DependencyProperty Enum N/A
IsFYNumberingEnabled Gets or sets the Fiscal Year Numbering. If this property is changed, it will be reflected in the schedule.By default FY Numbering is set to false. Dependency Property bool N/A
DefaultStartTime Gets or sets the task starting time in a day. This is based on the

GanttTime

class of the Gantt control.By default this is set to 9.00 AM
Dependency Property GanttTime N/A
DefaultEndTime Gets or sets the task ending time in a day. This is based on the

GanttTime

class of the Gantt control.By default this is set to 6.00 PM
Dependency Property GanttTime N/A
Weekends Gets or sets the weekend days. Default value is Saturday, Sunday. Dependency Property Days N/A
ShowWeekends Enables or disables the weekend days in schedule. Default value is true. Dependency Property bool N/A
ExcludeWeekends Excludes or includes the weekend days in duration calculation. Default value is false. Dependency Property bool N/A
ShowNonWorkingHoursBackground Enables or disables the background for weekend days. Default value is true. Dependency Property bool N/A

NOTE

Currently DefaultStartTime and DefaultEndTime will reflect only in the Chart Background Panel.

Adding Calendar Customization to an Application

Define the value to weekdays, months, FY Numbering, default start time and default end time as required and assign it to the appropriate APIs in the Gantt.

The following code illustrates adding Calendar Customization to an Application:

<!--Gantt Control Calendar Customization and Weekends Customization Info-->
<sync:GanttControl x:Name="Gantt" Grid.Row="1" WeekBeginsOn="Friday"    

                   Weekends="Wednesday,Thursday"

                   ItemsSource="{Binding TaskCollection}"   

                   FiscalYearBeginsOn="June"

                   IsFYNumberingEndbled="True" DefaultEndTime="16:00:00" 

                   ShowWeekends="True" ExcludeWeekends="True"   

                   DefaultStartTime="10:00:00"  

                   ShowNonWorkingHoursBackground="True">  

    <sync:GanttControl.TaskAttributeMapping>

        <sync:TaskAttributeMapping TaskIdMapping="Id"

                                   TaskNameMapping="Name"

                                   StartDateMapping="StDate" 

                                   ChildMapping="ChildTask"

                                   FinishDateMapping="EndDate"

                                   DurationMapping="Duration"

                                   ProgressMapping="Complete"

                                   PredecessorMapping="Predecessor">

        </sync:TaskAttributeMapping>

    </sync:GanttControl.TaskAttributeMapping>

</sync:GanttControl>
//To set WeekBeginsOn
Gantt.WeekBeginsOn = DayOfWeek.Friday;

//To set FY Numbering
Gantt.IsFYNumberingEndbled = true;

//To set FiscalYearBeginsOn
Gantt.FiscalYearBeginsOn = Month.June;

//To set DefaultStartTime
Gantt.DefaultStartTime = new TimeSpan(10,0,0);

//To set DefaultEndTime
Gantt.DefaultEndTime = new TimeSpan(16, 0, 0);

//To set Weekends
Gantt.Weekends = Days.Wednesday | Days.Thursday;

//To set ShowWeekends
Gantt.ShowWeekends = true;

//To set ExcludeWeekends
Gantt.ExcludeWeekends = true;

//To set ShowNonWorkingHoursBackground
Gantt.ShowNonWorkingHoursBackground = true;

// To Set FY Numbering
Gantt.IsFYNumberingEndbled = true;

The following image shows Customized Calender and Weekends:

Calendar-Customization_img1

Customized Calender

To view samples:

  1. Go to the Syncfusion Essential Studio installed location.
    Location: Installed Location\Syncfusion\Essential Studio\25.1.35\Infrastructure\Launcher\Syncfusion Control Panel
  2. Open the Syncfusion Control Panel in the above location (or) Double click on the Syncfusion Control Panel desktop shortcut menu.
  3. Click Run Samples for WPF under User Interface Edition panel.
  4. Select Gantt.
  5. Expand the Interactive Features item in the Sample Browser.
  6. Choose the Calendar Customization sample to launch.