MindFusion.Wpf Pack Programmer's Guide
Activities (Tasks)

Activities are represented in the object model by the IActivityViewModel interface. The root activities in the project hierarchy can be obtained from the Activities property of the IProjectViewModel. The subactivities of an activity can be accessed through its Subactivities property.

Creating New Activities

New activities can be created by calling the CreateActivity method. The first argument specifies the parent activity, the second argument specifies the 0-based position in the parent's children list where the new activity should be added. To create a root activity, pass null (Nothing in Visual Basic) as the first argument. Creating a new activity through the ViewModel is automatically reflected back to the Model if the Model implements the IList interface. The type of the newly created Model activity is specified by the ActivityType property of the project.

The following sample code creates and initializes a new activity in an existing project:

C#  Copy Code

var activity = project.CreateActivity(null, -1);
activity.ActivityName = "New activity";
var subactivity = project.CreateActivity(activity, -1);
subactivity.ActivityName = "New child activity";

Visual Basic  Copy Code

Dim activity = project.CreateActivity(Nothing, -1)
activity.ActivityName = "New activity"
Dim subactivity = project.CreateActivity(activity, -1)
subactivity.ActivityName = "New child activity"

Deleting Activities

Activities are deleted through the RemoveActivity method. Activity deletion is automatically reflected back to the Model if the Model implements the IList interface.

Modifying Activities

Activities can be modified through the properties exposed by the IActivityViewModel interface. All modifications to the activities are automatically reflected back to the Model through the binding expressions used to establish the mapping between the ViewModel and Model properties. For additional information about those binding expressions, check the Project topic.

Undo and Redo

All of the above operations are undoable. Check Undo and Redo for additional information.