WorkflowDesignerLoader.AddActivityToDesigner(Activity) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將活動加入至父活動集合後,再將活動加入至設計工具主應用程式。
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)
參數
範例
下列範例示範如何將 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