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