Edit this page

GanttTask Deadline

With the official Q2 2014 release of UI for WPF/SL you will have the option to use the Deadline property of the GanttTask and visualize an indicator showing whether the task is expired.

This help topic will describe the Deadline property in more details as well as how you could customize its behavior.

Overview

Setting the Deadline property of the GanttTask visualizes a vertical line showing the deadline for finishing the task as well as an indicator showing whether the task is on time or delayed.

Example 1 shows how the Deadline can be set.

var task = new GanttTask()
{
    Start = new DateTime(2014, 6, 6),
    End = new DateTime(2014, 6, 8),
    Deadline = new DateTime(2014, 6, 9),
    Title = "Gantt Rendering"
};
Dim task = New GanttTask() With { _
    .Start = New DateTime(2014, 6, 6), _
    .[End] = New DateTime(2014, 6, 8), _
    .Deadline = New DateTime(2014, 6, 9), _
    .Title = "Gantt Rendering" _
}

When the End time is before the set Deadline of the Task, the Indicator is in green color, however, as soon as you expand the task after the End, the Indicator is replaced with one that has red color.

Figure 1 shows how the Deadline and the Indicator are visualized in the Timeline part of the control.

Figure 1: Deadline and Indicatorganttview gantttaskdeadline 01

Customization

There may be cases when you need to add different logic for marking tasks as expired. The default implementation is as soon as the End goes after the Deadline, the task is marked as delayed.

In order to change this behavior, you will need to create a custom GanttTask and override its CheckIsExpired method. Example 2 demonstrates how to override this method, so that the task is marked as expired only when its Start property goes after the set Deadline:

Example 2 shows how to override CheckIsExpired method.

public class CustomGanttTask : GanttTask
{
    protected override bool CheckIsExpired()
    {
        return this.Deadline < this.Start;
    }
}
Public Class CustomGanttTask
    Inherits GanttTask
    Protected Overrides Function CheckIsExpired() As Boolean
        Return Me.Deadline < Me.Start
    End Function
End Class

Figure 2 and Figure 3 show the result:

Figure 2: Even if the End is after the Deadline, the task is not marked as expired.

ganttview gantttaskdeadline 02

Figure 3: As soon as the Start goes after the Deadline, the task is marked as delayed.

ganttview gantttaskdeadline 03

See Also