WorkComplete setting does not work for Parent activities

Technote (FAQ)

Question

How to force the parent activity's WorkComplete property automatically updated when changes occur in its child activities?

Cause

Calculating the WorkComplete value of a parent activity is highly dependent on the application requirements. For instance, you can decide that it should be the minimum of all the child's WorkComplete value. But in an other situation, you can decide that it should be the average value of the child WorkComplete, or even if some child tasks are more important than others, some ponderated values. With that in mind, the WorkComplete behavior has not been implemented for the parent activities, which by default will remain at 0 regardless of children activities WorkComplete.

Answer

To change this default behavior and automatically calculate the parent activity's WorkComplete each time one child WorkComplete is updated, you can listen to ActivitiesChanged events.

The code below demonstrates how to set the parent activity's WorkComplete value to the minimum value of all its child's WorkComplete :