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,其可以設定為父系。

傳回

如果 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 是否可以成為設計工具的父系時,這個方法很實用。

當使用者啟始拖放或貼上等插入作業時,便會呼叫這個方法。

適用於