PickBranch.Action 属性

定义

要在已触发执行此分支的情况下执行的 Activity

public:
 property System::Activities::Activity ^ Action { System::Activities::Activity ^ get(); void set(System::Activities::Activity ^ value); };
[System.Windows.Markup.DependsOn("Trigger")]
public System.Activities.Activity Action { get; set; }
[<System.Windows.Markup.DependsOn("Trigger")>]
member this.Action : System.Activities.Activity with get, set
Public Property Action As Activity

属性值

要执行的活动。

属性

示例

下面的代码示例演示如何设置 PickBranch 活动的 Action 属性。 此示例摘自 使用选取活动 示例。

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;
}

适用于