다음을 통해 공유


WorkflowDesignerLoader.AddActivityToDesigner(Activity) 메서드

정의

활동이 부모 활동 컬렉션에 추가되면 디자이너 호스트에 활동을 추가합니다.

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)

매개 변수

activity
Activity

추가할 Activity입니다.

예제

다음 예제에서는 CodeActivity을 디자이너에 추가하는 방법을 보여 줍니다. 활동은 AddActivityToDesigner 메서드를 사용하여 디자이너에 추가되기 전에 워크플로 내에서 루트 활동의 Activities 컬렉션에 추가됩니다.

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

적용 대상