Επεξεργασία

Κοινή χρήση μέσω


WorkflowDesignerLoader.AddActivityToDesigner(Activity) Method

Definition

Adds an activity to the designer host after it has been added to the parent activities collection.

public:
 void AddActivityToDesigner(System::Workflow::ComponentModel::Activity ^ activity);
public void AddActivityToDesigner (System.Workflow.ComponentModel.Activity activity);
member this.AddActivityToDesigner : System.Workflow.ComponentModel.Activity -> unit
Public Sub AddActivityToDesigner (activity As Activity)

Parameters

activity
Activity

Activity to add.

Examples

The following example demonstrates how to add a CodeActivity to the designer. Before the activity is added to the designer using the AddActivityToDesigner method, it is first added to the Activities collection of the root activity within the workflow.

public void AddCodeActivityToDesigner()
{
    WorkflowDesignerLoader loader = GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
    if (loader == null)
        return;

    IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost));
    CompositeActivity rootActivity = designerHost.RootComponent as CompositeActivity;

    CodeActivity codeActivity = new CodeActivity();
    rootActivity.Activities.Add(codeActivity);
    loader.AddActivityToDesigner(codeActivity);
    return;
}
Public Sub AddCodeActivityToDesigner()

    Dim loader As WorkflowDesignerLoader = CType(GetService(GetType(WorkflowDesignerLoader)), WorkflowDesignerLoader)
    If loader Is Nothing Then Return
    Dim designerHost As IDesignerHost = CType(GetService(GetType(IDesignerHost)), IDesignerHost)
    Dim rootActivity As CompositeActivity = CType(designerHost.RootComponent, CompositeActivity)
    Dim codeActivity As New CodeActivity()
    rootActivity.Activities.Add(codeActivity)
    loader.AddActivityToDesigner(codeActivity)
    Return
End Sub

Applies to