ActivityDesigner.CanBeParentedTo(CompositeActivityDesigner) 方法

定义

返回一个值,该值指示 CompositeActivity 能否设置与设计器关联的活动的父级。

public:
 virtual bool CanBeParentedTo(System::Workflow::ComponentModel::Design::CompositeActivityDesigner ^ parentActivityDesigner);
public virtual bool CanBeParentedTo (System.Workflow.ComponentModel.Design.CompositeActivityDesigner parentActivityDesigner);
abstract member CanBeParentedTo : System.Workflow.ComponentModel.Design.CompositeActivityDesigner -> bool
override this.CanBeParentedTo : System.Workflow.ComponentModel.Design.CompositeActivityDesigner -> bool
Public Overridable Function CanBeParentedTo (parentActivityDesigner As CompositeActivityDesigner) As Boolean

参数

parentActivityDesigner
CompositeActivityDesigner

可能会设置为父级的 CompositeActivityDesigner

返回

Boolean

如果 CompositeActivity 可设置为与设计器关联的活动的父级,则为 true;否则为 false

示例

下面的示例演示如何确保自定义活动成为特定活动类型的父级。 在本例中,自定义活动只能成为 ParallelIfActivity 的父级。

public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
{
    if (null == parentActivityDesigner)
        throw new ArgumentNullException("parentActivityDesigner");

    if (!(parentActivityDesigner.Activity is ParallelIfActivity))
        return false;
    else
        return base.CanBeParentedTo(parentActivityDesigner);
}
Public Overrides Function CanBeParentedTo(ByVal parentActivityDesigner As CompositeActivityDesigner) As Boolean
    If parentActivityDesigner Is Nothing Then
        Throw New ArgumentNullException("parentActivityDesigner")
    End If

    If Not TypeOf parentActivityDesigner.Activity Is ParallelIfActivity Then
        Return False
    Else
        Return MyBase.CanBeParentedTo(parentActivityDesigner)
    End If
End Function

注解

此方法对于测试特定的 CompositeActivityDesigner 能否成为设计器的父级十分有用。

当用户启动插入操作(如拖放或粘贴)时,会调用此方法。

适用于