Partilhar via


WorkflowDesignerLoader.AddActivityToDesigner(Activity) Método

Definição

Adiciona uma atividade no host do designer depois que ele foi adicionado à coleção de atividades pai.

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)

Parâmetros

activity
Activity

Activity a ser adicionado.

Exemplos

O exemplo a seguir demonstra como adicionar um CodeActivity ao designer. Antes que a atividade seja adicionada ao designer usando o AddActivityToDesigner método , ela é adicionada pela primeira vez à coleção Activities da atividade raiz dentro do fluxo de trabalho.

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

Aplica-se a