StructuredCompositeActivityDesigner.ContainedDesigners Property


Gets a generic read-only collection that contains all activity designers that are children of the StructuredCompositeActivityDesigner.

Namespace:   System.Workflow.ComponentModel.Design
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

public override ReadOnlyCollection<ActivityDesigner> ContainedDesigners { get; }

Property Value

Type: System.Collections.ObjectModel.ReadOnlyCollection<ActivityDesigner>

An ActivityDesigner read-only collection that contains the child designers.

The following example demonstrates the addition of a new branch using a designer based off of the CompositeActivityDesigner class. If CanInsertActivities returns true, a new branch is created using the InsertActivities method. A ConnectorHitTestInfo object is created as a parameter to the InsertActivities method. When this is finished, the EnsureVisibleContainedDesigner method is used to ensure that the newly added branch is displayed in the workflow designer by accessing a single object in the ContainedDesigners collection.

protected override CompositeActivity OnCreateNewBranch()
    return new ParallelIfBranch();

private void OnAddBranch(object sender, EventArgs e)
    CompositeActivity activity1 = this.OnCreateNewBranch();
    CompositeActivity activity2 = base.Activity as CompositeActivity;

    if ((activity2 != null) && (activity1 != null))
        int num1 = this.ContainedDesigners.Count;
        Activity[] activityArray1 = new Activity[] { activity1 };

        if (CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count),
            new List<Activity>(activityArray1).AsReadOnly()))
                new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count),
                new List<Activity>(activityArray1).AsReadOnly(),
                string.Format("Adding branch {0}", activity1.GetType().Name));

            if ((this.ContainedDesigners.Count > num1) && (this.ContainedDesigners.Count > 0))
                this.ContainedDesigners[this.ContainedDesigners.Count - 1].EnsureVisible();

.NET Framework
Available since 3.0
Return to top