GanttView for WPF | ComponentOne
Task Elements / Milestone Task
In This Topic
    Milestone Task
    In This Topic

    A milestone task, or simply a milestone, is used for accounting an important event(s) within a project schedule. This feature helps users in keeping a track of their planned goals. For example, you can create a milestone to mark events such as the completion of a major phase in project schedule or to indicate the beginning of the next project phase, etc. Since milestones do not include or account for any work, these are created as tasks with zero duration.

    In GanttView, a milestone task is represented by a diamond-shaped item in the chart view as shown in the following image.

    Milestone Task

    GanttView supports milestones, which can be created as a task with the Duration property set to zero, and the Start and the Finish properties set to the same date. Milestone tasks can also be created at the design time through the Task Collection Editor available from the Properties window.

    To create a milestone task using code, you need to define an instance of the Task class, and set the Name, Duration, Start, and Finish properties. Then, you can add the created task to GanttView using the Add method as demonstrated in the following code.

    C#
    Copy Code
    //Creating a milestone task
    Task milestone_task = new Task();
    milestone_task.Name = "Project Review - Phase 1";
    milestone_task.Start = new DateTime(2022 , 4, 29);
    milestone_task.Finish = new DateTime(2022, 4, 29);
    milestone_task.Duration = 0;
    
    //Adding milestone task to gantt view
    gv.Tasks.Add(milestone_task);