Version

The Selected Activities Collection

The xamSchedule includes a number of view controls including xamDayView, xamMonthView and xamScheduleView. Each of these controls offers the end user the ability to select one or more scheduling activities.

When the user clicks on an activity in one of the xamSchedule view controls the following actions are performed:

  1. If the activity is not being edited in place then focus is set to the view control.

  2. If not already active, the ResourceCalendar that the activity is associated with is activated. This sets the view control’s ActiveCalendar property and raises its ActiveCalendarChanged event.

  3. If the ResourceCalendar is in a CalendarGroup then the group’s SelectedCalendar property is set to the ResourceCalendar.

  4. All currently selected activities that are associated with different ResourceCalendars are removed from the SelectedActivities collection.

  5. If the ‘Ctrl’ key is pressed:

    1. If the activity is already in the SelectedActivities collection it is removed.

    2. If the activity is not already in the SelectedActivities collection it is added.

    3. The SelectedActivitiesChanged event is raised.

  1. If the ‘Ctrl’ key is not pressed:

    1. All other activities that are associated with the same ResourceCalendar are removed from the SelectedActivities collection.

    2. If the activity is not already in the SelectedActivities collection it is added.

    3. If any changes were made to the SelectedActivities collection by 4, 5a and 5b above then the SelectedActivitiesChanged event is raised.

  1. All activities associated with the SelectedCalendar in their respective CalendarGroups will appear bolder than activities associated with other ResourceCalendars.

  2. All activities in the SelectedActivities collection will appear with thicker borders than other activities and will display resize handles if resizing of the activity is allowed.

Note: The SelectedActivities collection, the ActiveCalendar property and the CalendarGroup’s SelectedCalendar property can be set in code. It is the caller’s responsibility in this case to synchronize these properties to sure they make sense. For example, to select an activity the caller should clear the SelectedActivities collection of activities from other ResourceCalendars and set the ActiveCalendar property appropriately.

xamSchedule SelectedActivity.png

The following example shows how to listen for changes in the SelectedActivities collection:

In Visual Basic:

dayView.SelectedActivitiesChanged += _
    New EventHandler(Of SelectedActivitiesChangedEventArgs) _
   (dayView_SelectedActivitiesChanged)
Private Sub dayView_SelectedActivitiesChanged(sender As Object, _
    e As SelectedActivitiesChangedEventArgs)
        For Each activity As var In dayView.SelectedActivities
        ' here the developer has all the ActivityBase info like
        ' activity.Id and the actual activity in activity.DataItem
        ' property
        Next
End Sub

In C#:

dayView.SelectedActivitiesChanged +=
    new EventHandler<SelectedActivitiesChangedEventArgs>
    (dayView_SelectedActivitiesChanged);
void dayView_SelectedActivitiesChanged(object sender,
    SelectedActivitiesChangedEventArgs e)
{
    foreach (var activity in dayView.SelectedActivities)
    {
        // here the developer has all the ActivityBase info like
        // activity.Id and the actual activity in activity.DataItem
        // property
    }
}