共用方式為


Pick.Branches 屬性

定義

PickBranch 物件的集合,Pick 活動可能會根據傳入事件執行其中一個物件。

public:
 property System::Collections::ObjectModel::Collection<System::Activities::Statements::PickBranch ^> ^ Branches { System::Collections::ObjectModel::Collection<System::Activities::Statements::PickBranch ^> ^ get(); };
public System.Collections.ObjectModel.Collection<System.Activities.Statements.PickBranch> Branches { get; }
member this.Branches : System.Collections.ObjectModel.Collection<System.Activities.Statements.PickBranch>
Public ReadOnly Property Branches As Collection(Of PickBranch)

屬性值

分支集合。

範例

下列程式碼範例將示範如何設定 Pick 活動的 Branches 屬性。 此範例來自 使用挑選活動 範例。

static Activity CreateWF()
{
    Variable<string> name = new Variable<string>();
    Sequence body = new Sequence
    {
        Variables = { name },
        Activities =
        {
            new WriteLine { Text = "What is your name? (You have 5 seconds to answer)" },
            new Pick
            {
               Branches =
               {
                   new PickBranch
                    {
                       Trigger = new ReadString
                       {
                           Result = name,
                           BookmarkName = bookmarkName
                       },
                       Action = new WriteLine
                       {
                           Text = new InArgument<string>(env => "Hello " + name.Get(env))
                       }
                   },
                   new PickBranch
                    {
                       Trigger = new Delay
                       {
                           Duration = TimeSpan.FromSeconds(5)
                       },
                       Action = new WriteLine
                       {
                           Text = "Time is up."
                       }
                   }
               }
           }
       }
    };

    return body;
}

適用於