WorkflowDesignerLoader.AddActivityToDesigner(Activity) Method

Definition

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

C#
public void AddActivityToDesigner(System.Workflow.ComponentModel.Activity 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.

C#
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;
}

Applies to

Proizvod Verzije
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1