MindFusion.Scheduling for Silverlight Programmer's Guide
Tutorial 2: Adding Dependencies to the Chart

This tutorial shows how to enable dependencies between activities in an project using MindFusion.DataViews for Silverlight

1. Create and initialize a new Silverlight application project

Follow steps 1 through 4 from Tutorial 1.

2. Create dependencies between the activities in the chart

To create the dependencies you could use the built-in Dependency class, but you are not limited to it and can use you own custom created class that implements the IDependency interface. First, create a collection that will hold the Dependency objects.

C#  Copy Code

ObservableCollection<Dependency> dependencies = new ObservableCollection<Dependency>();

Visual Basic  Copy Code

Dim dependencies As New ObservableCollection(Of Dependency)()

Next, create some dependencies between the existing Activity objects and add them to the underlying collection.

C#  Copy Code

dependencies.Add(new Dependency() { From = a0, To = a1, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a0, To = a2, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a2, To = a3, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a1, To = a4, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a3, To = a4, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a1, To = a5, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a4, To = a6, DependencyType = DependencyType.FinishToStart });
dependencies.Add(new Dependency() { From = a5, To = a6, DependencyType = DependencyType.FinishToStart });

Visual Basic  Copy Code

dependencies.Add(New Dependency() With { _
 .From = a0, _
 .[To] = a1, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a0, _
 .[To] = a2, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a2, _
 .[To] = a3, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a1, _
 .[To] = a4, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a3, _
 .[To] = a4, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a1, _
 .[To] = a5, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a4, _
 .[To] = a6, _
 .DependencyType = DependencyType.FinishToStart _
})
dependencies.Add(New Dependency() With { _
 .From = a5, _
 .[To] = a6, _
 .DependencyType = DependencyType.FinishToStart _
})

3. Create the project and associate it with the view

Modify the project initialization from the previous tutorial to include the newly created dependencies like this:

C#  Copy Code

IProjectViewModel project = activityView.CreateViewModel(activities, dependencies, null, nulltypeof(Activity), typeof(Dependency), null, null);

Visual Basic  Copy Code

Dim project As IProjectViewModel = activityView.CreateViewModel(activities, dependencies, Nothing, NothingGetType(Activity), GetType(Dependency), Nothing, Nothing)

4. Build and run

Compile and run the application. The result should look similar to the image below:

 Note

You can find the complete source code of this tutorial in the product installation folder, under the folder for the appropriate .NET version and language.