Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

PickBranch Constructor

.NET Framework 4.6 and 4.5

Creates a new instance of the PickBranch activity.

Namespace:  System.Activities.Statements
Assembly:  System.Activities (in System.Activities.dll)

public PickBranch()

The following code sample demonstrates creating a PickBranch activity. This example is from the Using the Pick Activity sample.

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

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4
Show:
© 2015 Microsoft