Dynamic Workflows with XAML

Posted: April 17, 2010 in C#, Programming
Tags: , ,

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.

In this tutorial, i will use exiting code that already created here.

Fisrt, in Solution Explorer, rename file Workflow1.xaml into MyWorkflow.xaml. Oh yeah, do not forget to change class name in xaml code, simply right click MyWorkflow.xaml and choose “View Code”.

Next step, you need to tell Visual Studio to treat MyWorkflow.xaml as content that must be deployed rather than code that must be built. To do this In Solution Explorer select MyWorkflow.xamland then in Properties Window, change the configuration :

Previously your class was compiled into a type. To invoke a workflow from a .xaml file you will need to modify Program.cs to be like this :

using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;
using System.Activities.XamlIntegration;

namespace WorkflowTest1
{
    class Program
    {
        static void Main(string[] args)
        {
            WorkflowInvoker.Invoke(ActivityXamlServices.Load("MyWorkflow.xaml"));
            Console.ReadKey();
        }
    }
}

Run the program…

Comments
  1. LunaLight says:

    nice posting gan ^^…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s