Exercise 4: Dynamic Workflows with XAML
Up to this point, you have been authoring workflows in .xaml, .cs or .vb files. These files are compiled into types that are included in the assembly of the project and run by the workflow runtime.
While it might look like the format of the source files does not matter, .xaml files offer some distinct advantages over authoring workflows in C# or VB.
Dynamic workflows provide some interesting possibilities for programs that want to generate business logic or make a runtime decision on which business logic to load and run.
Task 0 – Opening the Solution
To begin this exercise you can use the solution you finished from Exercise 3. Alternatively, you can follow the following steps to begin with Exercise 4.
Task 1 – Modifying SayHello.xaml Files Properties
In this task you will modify the HellowWorkflow program to load and run the SayHello.xaml file. Then you will modify the text of SayHello.xaml and observe the change in the message the next time you run the application.
Task 2 – Modifying Main() to Load the SayHello.xaml File
Previously your workflow was compiled into a type. To invoke a workflow from a .xaml file you will need to use ActivityXamlServices to load the .xaml file into memory and create an instance of an activity that WorkflowInvoker can invoke. Keep in mind that any assemblies that your .xaml file references must be available when the workflow is invoked.