Skip to main content

How to: Set Custom Work Time Intervals (legacy)

  • 2 minutes to read


You are viewing documentation for the legacy WPF Scheduler control. If you’re starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

This example demonstrates how to set a custom work time for each day and resource.

To do this, handle the SchedulerControl.QueryWorkTime event, check values of the QueryWorkTimeEventArgs.Interval and QueryWorkTimeEventArgs.Resource properties and set the QueryWorkTimeEventArgs.WorkTime property value, as required.

using DevExpress.XtraScheduler;
using DevExpress.Xpf.Scheduler;

// Create a collection of different worktime intervals.
TimeOfDayInterval[] workTimes = new TimeOfDayInterval[] {
    new TimeOfDayInterval(TimeSpan.FromHours(0), TimeSpan.FromHours(16)),
    new TimeOfDayInterval(TimeSpan.FromHours(10), TimeSpan.FromHours(20)),
    new TimeOfDayInterval(TimeSpan.FromHours(7), TimeSpan.FromHours(15)),
    new TimeOfDayInterval(TimeSpan.FromHours(16), TimeSpan.FromHours(24)),

private void schedulerControl1_QueryWorkTime(object sender, QueryWorkTimeEventArgs e) {

    if(schedulerControl1.Storage.ResourceStorage == null)

    int resourceIndex = schedulerControl1.Storage.ResourceStorage.Items.IndexOf(e.Resource);
    if(resourceIndex >= 0) {
        if(resourceIndex == 0) {
        // Specify alternate worktimes for odd and even days.
            if((e.Interval.Start.Day % 2) == 0)
                e.WorkTime = workTimes[resourceIndex % workTimes.Length];
                e.WorkTime = TimeOfDayInterval.Empty;
        else {
            // Specify worktime interval if the current date is treated as a working day.
            if (schedulerControl1.WorkDays.IsWorkDay(e.Interval.Start.Date))
                e.WorkTime = workTimes[resourceIndex % workTimes.Length];