Version

Other Events and Events Arguments

Topic Overview

Purpose

This topic describes some of the available events triggered by common user interactions in the xamGantt™ control.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic describes how the xamGantt control is bound to an arbitrary tasks collection via ListBackedProject.

XamGantt Configuration Events Summary

XamGantt configuration events summary chart

The following table lists some of the events invoked while manipulating the xamGantt control user interface.

These events have the suffix “ing” or “ed” appended to them, reflecting the order in which they occur.

The (-ing) events are cancelable and are invoked before the (-ed) events.

Code Example: Canceling Milestones Dragging

Description

The code snippet demonstrates how to disable milestones dragging.

The XamGantt TaskBarDragging event is handled in order to check if a task is a milestone and if it is – cancel its dragging.

Code

In XAML:

<ig:ListBackedProject x:Name="dataProvider" TaskItemsSource="{Binding Tasks}">
    <ig:ListBackedProject.TaskPropertyMappings>
        <!-- Add Project Task Property Mappings Here -->
    </ig:ListBackedProject.TaskPropertyMappings>
</ig:ListBackedProject>
<ig:XamGantt x:Name="gantt"
             Project="{Binding ElementName=dataProvider}"
             TaskBarDragging="gantt_TaskBarDragging"/>

In C#:

private void gantt_TaskBarDragging(object sender, GanttTaskBarDraggingEventArgs e)
{
    // If a task is a milestone, prevent dragging
    if (e.Task.IsMilestone)
    {
        e.Cancel = true;
    }
}

In Visual Basic:

Private Sub gantt_TaskBarDragging(sender As Object, e As GanttTaskBarDraggingEventArgs)
    ' If a task is a milestone, prevent dragging
    If e.Task.IsMilestone Then
        e.Cancel = True
    End If
End Sub

Project Configuration Events Summary

Project configuration events summary chart

The following table lists some of Project class events that are invoked while manipulating the project and project tasks.

These events have the suffix “ing” or “ed” appended to them, reflecting the order in which they occur.

The (-ing) events are cancelable and are invoked before the (-ed) events. Both events handlers expose information about the ProjectTask associated with the event.

In order to: Use this event: The event argument exposes the following information:

Handle summary task collapsing

Handle task deleting

Handle summary task expanding

Handle task indenting

Handle task inserting

Handle task outdenting

Code Example: Confirming Task Deletion

Description

The code snippet demonstrates how deleting a task may be confirmed or canceled depending on the user actions.

After a right mouse click on a task in the xamGantt grid area, a context menu appears with the Delete option. If a user chooses to delete the selected task, a message box displays with two button options – OK and Cancel. If a user clicks the Cancel button, the deleting event is omitted. If the user clicks the OK button, the task is deleted.

Note
Note

Multiple tasks can be deleted in one single operation and the code in the example executes for every deleted task.

Code

In XAML:

<ig:ListBackedProject x:Name="dataProvider"
                      TaskItemsSource="{Binding Tasks}"
                      TaskDeleting="dataProvider_TaskDeleting">
    <ig:ListBackedProject.TaskPropertyMappings>
        <!-- Add Project Task Property Mappings Here -->
    </ig:ListBackedProject.TaskPropertyMappings>
</ig:ListBackedProject>
<ig:XamGantt x:Name="gantt"
             Project="{Binding ElementName=dataProvider}" />

In C#:

using Infragistics.Controls.Schedules;
private void dataProvider_TaskDeleting(object sender, ProjectTaskDeletingEventArgs e)
{
string msg = String.Format("Are you sure you want to delete {0} task?", e.Task.TaskName);
MessageBoxResult result = MessageBox.Show(msg, "Confirmation", MessageBoxButton.OKCancel);
    if (result == MessageBoxResult.Cancel)
    {
        // Cancel task deletion
        e.Cancel = true;
    }
}

In Visual Basic:

Imports Infragistics.Controls.Schedules
Private Sub dataProvider_TaskDeleting(sender As System.Object, e As ProjectTaskDeletingEventArgs)
  Dim msg As String = [String].Format("Are you sure you want to delete {0} task?", e.Task.TaskName)
Dim result As MessageBoxResult = MessageBox.Show(msg, "Confirmation", MessageBoxButton.OKCancel)
    If result = MessageBoxResult.Cancel Then
        ' Cancel task deletion
        e.Cancel = True
    End If
End Sub

Related Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic describes the properties and events used to set or retrieve the currently active cell, column or row in the xamGantt control.

This topic describes some of the available events triggered by common user interactions in the xamGantt control.