WorkflowDesignerLoader.RemoveActivityFromDesigner(Activity) 方法

定义

当将活动添加到父活动集合中后,从设计器宿主中移除该活动。

public:
 void RemoveActivityFromDesigner(System::Workflow::ComponentModel::Activity ^ activity);
public void RemoveActivityFromDesigner (System.Workflow.ComponentModel.Activity activity);
member this.RemoveActivityFromDesigner : System.Workflow.ComponentModel.Activity -> unit
Public Sub RemoveActivityFromDesigner (activity As Activity)

参数

activity
Activity

要从设计器中移除的活动。

示例

下面的示例演示如何从 WorkflowDesignerLoader 中移除活动。 在从 WorkflowDesignerLoader 中移除工作流中的最后一个子活动前,首先从工作流的 Activities 集合中移除该子活动。

public void RemoveLastChildActivity()
{
    IDesignerHost designerHost = (IDesignerHost)GetService(typeof(IDesignerHost));
    CompositeActivity rootActivity = designerHost.RootComponent as CompositeActivity;

    if (rootActivity.Activities.Count > 0)
    {
        Activity activityToRemove = rootActivity.Activities[rootActivity.Activities.Count - 1];
        rootActivity.Activities.Remove(activityToRemove);
        this.RemoveActivityFromDesigner(activityToRemove);
    }
}
Public Sub RemoveLastChildActivity()
    Dim designerHost As IDesignerHost = CType(GetService(GetType(IDesignerHost)), IDesignerHost)
    Dim rootActivity As CompositeActivity = CType(designerHost.RootComponent, CompositeActivity)

    If rootActivity.Activities.Count > 0 Then
        Dim activityToRemove As Activity = rootActivity.Activities(rootActivity.Activities.Count - 1)
        rootActivity.Activities.Remove(activityToRemove)
        Me.RemoveActivityFromDesigner(activityToRemove)
    End If
End Sub

适用于