1. Program Name of the Activity
System.Activities.Statements.If
2. Explanation
- Studio Version ~2.0.2.0
Quick Access: "Toolbox" > "Control Flow" > "If" - Studio Version 2.0.3.0~
Quick Access: "Toolbox" > "System" > "Control Flow" > "If"
This activity is used when you want to branch the processing in a workflow based on specific conditions.
3. Properties
4. How to Use
From the Activity Panel, place the "If" activity.
In the diagram below, configure each field as follows:
- Condition: Enter the condition for branching processing.
- Then: Place the activity to be performed if the condition is True.
- Else: Place the activity to be performed if the condition is False.
Example: Display a dialog asking for the capital of Vietnam, and change the message in the Message Box depending on whether the entered answer is "Ha Noi"
First, place the "Input Dialog" activity above the "If" activity.
In the Input Dialog's "Input > Title" property, enter "Which is the capital of Vietnam", and in the "Output > Result" property, set an Object type variable called answer.
For more details on setting variables, refer to "Creating Variables."
Set the "Condition" field in the "If" activity to answer.ToString = "Ha Noi". (You can also write it as "Ha Noi" = answer.ToString, which has the same meaning.)
In the Then field, place a "Message Box" and set the "Input > Text" property to "true", and the "Input > Buttons" property to "Ok."
In the Else field, place another "Message Box" and set the "Input > Text" property to "false", and the "Input > Buttons" property to "Ok."
After completing all settings, it should look like this:
When executed, the following dialog appears first:
If you enter "Ha Noi" and click the "OK" button, the message "True" is displayed.
On the other hand, if you enter anything other than "Ha Noi" and click the button, the message "False" is displayed.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article