It works on my machine

Learning WF - Part 2

In the first part we looked at what WF was and what would the simplest workflow would look like in code. Let's move on and use the tools that WF is meant to be used with. First of all, WF follows the same principles you find in other technologies that come with .Net 3.0, especially the Markup + Code = Application thing. You can completely code the workflow or you could break it up into code and markup. The markup being XAML.

I will create a simple workflow called, you guessed correctly, SimpleWorkflow. Also I am using VS 2008, so some screenshots may look slightly different than VS 2005.ScreenHunter_05 Apr. 19 22.20

If you right click the project and add new item, select workflow you see a number of options. Among them you have sequential and state workflow with code and sequential and state workflow with code separation. We select the sequential workflow with code separation meaning we generate a XAML file and a code behind file.ScreenHunter_06 Apr. 19 22.25

Workflow designer pops up. Let's drop a code activity in the designer and add some code to it, by double clicking the activity.

ScreenHunter_07 Apr. 19 22.34

ScreenHunter_08 Apr. 19 22.34

Now the workflow is ready, but we chose the empty project for workflow so we don't have a code that host's this workflow. Let's add a class with the main function and add the hosting code too.

ScreenHunter_10 Apr. 19 22.36

Running this code should give us the obvious result.

ScreenHunter_11 Apr. 19 22.38

Now coming back to the code/XAML separation thing. This time we created one such workflow so let's look into that separation.

ScreenHunter_12 Apr. 19 22.40

As you can see the XAML file has the extension xoml here (interesting!) and code has the usual one. If you double click the xoml file then it would open the designer, so you need to do a right click and open with the XML editor. Then you see this (slightly reformatted to fit the screen).

ScreenHunter_13 Apr. 19 22.41

It should be quite obvious how the markup is composed and how it links with the code. If you have worked with ASP.Net then it pretty much the same deal. This concludes the second part. In the next part we will look at using some simple activities.

Posted: Apr 24 2008, 20:15 by raza | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .Net | WF
blog comments powered by Disqus