<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US"><title type="html">Matt W's Windows Workflow Place</title><subtitle type="html" /><id>http://blogs.msdn.com/mwinkle/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/mwinkle/default.aspx" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2009-02-12T21:03:52Z</updated><link rel="self" href="http://feeds.feedburner.com/wfguy" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry><title>Displaying Validation Errors in a Rehosted WF4 Designer</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/aMfkFwW6qd0/displaying-validation-errors-in-a-rehosted-wf4-designer.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/11/06/displaying-validation-errors-in-a-rehosted-wf4-designer.aspx</id><published>2009-11-06T18:55:30Z</published><updated>2009-11-06T18:55:30Z</updated><content type="html">&lt;p&gt;Here’s a quick one&lt;/p&gt;  &lt;h2&gt;“I’d like to find out if the workflow in the designer is valid… is there someway to retrieve the validation errors?”&lt;/h2&gt;  &lt;p&gt;Yes, the short answer is that you need to provide an implementation &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.validation.ivalidationerrorservice%28VS.100%29.aspx"&gt;IValidationErrorService&lt;/a&gt;.&amp;#160; There is one important method to implement on this interface, &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.validation.ivalidationerrorservice.showvalidationerrors%28VS.100%29.aspx"&gt;ShowValidationErrors&lt;/a&gt; which will pass you a list of &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.validation.validationerrorinfo%28VS.100%29.aspx"&gt;ValidationErrorInfo&lt;/a&gt; objects.&lt;/p&gt;  &lt;p&gt;The next thing that needs to happen is that you need to publish an instance of that new type to the editing context. &lt;/p&gt;  &lt;p&gt;Let’s look at a really simple implementation that will write out the validation errors to the debug log.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Presentation.Validation;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Diagnostics;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; VariableFinderShell
{
    &lt;span class="kwrd"&gt;class&lt;/span&gt; DebugValidationErrorService : IValidationErrorService
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ShowValidationErrors(IList&amp;lt;ValidationErrorInfo&amp;gt; errors)
        {
            errors.ToList().ForEach(vei =&amp;gt; Debug.WriteLine(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Error: {0} &amp;quot;&lt;/span&gt;, vei.Message)));
        }
    }
}&lt;/pre&gt;

&lt;p&gt;The final bit is to publish this to the editing context:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;wd.Context.Services.Publish&amp;lt;IValidationErrorService&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; DebugValidationErrorService());&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now, when editing the workflow in the rehosted app, let’s introduce some errors and then look at the output window.&amp;#160; Note, most &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DisplayingValidationErrorsinaRehostedWF4_9585/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DisplayingValidationErrorsinaRehostedWF4_9585/image_thumb.png" width="604" height="303" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918740" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/aMfkFwW6qd0" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="designer" scheme="http://blogs.msdn.com/mwinkle/archive/tags/designer/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/11/06/displaying-validation-errors-in-a-rehosted-wf4-designer.aspx</feedburner:origLink></entry><entry><title>Got a cool .NET app? Hang with Tortoises for 12 days</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/xZCHkwZn3qM/got-a-cool-net-app-hang-with-tortoises-for-12-days.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/11/06/got-a-cool-net-app-hang-with-tortoises-for-12-days.aspx</id><published>2009-11-06T17:15:59Z</published><updated>2009-11-06T17:15:59Z</updated><content type="html">&lt;p&gt;&lt;em&gt;&lt;a href="http://www.flickr.com/photos/mikeweston/333093049/sizes/l/"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="tortoise" border="0" alt="tortoise" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/Gotacoo.NETappHangwithTortoisesfor12days_B138/tortoise_3.jpg" width="327" height="254" /&gt;&lt;/a&gt; &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;photo courtesy of flickr user &lt;a href="http://www.flickr.com/photos/mikeweston/"&gt;mikeweston&lt;/a&gt;&amp;#160;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This is a something that the .NET team is putting together that has a &lt;a href="http://www.mydotnetstory.com/submit.aspx"&gt;contest&lt;/a&gt; with super cool prizes (seriously, 12 day trip to the Galapagos, for real (as my 4 year old says)).&amp;#160; (obligatory legalese &lt;a href="http://mydotnetstory.com/rules.aspx"&gt;here&lt;/a&gt;). If you’ve built a sweet app with the .NET framework, we’d like to hear about it.&amp;#160;&amp;#160; So check out &lt;a href="http://www.myDotNetStory.com"&gt;http://www.myDotNetStory.com&lt;/a&gt; today and enter to win.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918679" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/xZCHkwZn3qM" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="Microsoft" scheme="http://blogs.msdn.com/mwinkle/archive/tags/Microsoft/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/11/06/got-a-cool-net-app-hang-with-tortoises-for-12-days.aspx</feedburner:origLink></entry><entry><title>Finding the Variables in Scope Within the WF Designer</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/p1HoDIkfX54/finding-the-variables-in-scope-within-the-wf-designer.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/11/06/finding-the-variables-in-scope-within-the-wf-designer.aspx</id><published>2009-11-06T06:21:35Z</published><updated>2009-11-06T06:21:35Z</updated><content type="html">&lt;p&gt;In this &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/53c91c81-02cf-4eab-b43f-c3d73a03c501"&gt;thread&lt;/a&gt;, one of our forum customers asked the question:&lt;/p&gt;  &lt;h2&gt;“how do I find all of the variables that are in scope for a given activity in the designer?”&lt;/h2&gt;  &lt;p&gt;We do not have a public API to do this.&amp;#160; Internally we have a helper type called VariableHelper that we use to display the list of variables in the variable designer, as well as passed into the expression text box intellisense control. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_thumb.png" width="603" height="280" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_thumb_1.png" width="319" height="235" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;One thing that I would like to point out is that if you are implementing your expression editor and want to be able to enumerate the variables (to highlight the tokens that are in scope), your implementation of &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.view.iexpressioneditorservice.createexpressioneditor(VS.100).aspx"&gt;IExpressionEditorService.CreateExpressionEditor&lt;/a&gt;() will get a list of model items that correspond to the inscope variables.&amp;#160; &lt;/p&gt;  &lt;p&gt;Now, if you are not building an expression editor, and want to be able to enumerate all of the in scope variables, you will need to do a little more work.&amp;#160; Here are the basic steps&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Go to parent container&lt;/li&gt;    &lt;li&gt;Does it contain variables*&lt;/li&gt;    &lt;li&gt;Does it have a parent?&lt;/li&gt;    &lt;li&gt;Go to parent’s parent&lt;/li&gt;    &lt;li&gt;Repeat from step 2&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;* This is basically the tricky part, because it is not something we can cleanly determine (and it can also be altered at runtime by adding some additional ones via the CacheMetadata() method.&amp;#160; I’ll describe what the designer is currently doing to accumulate this list, and then talk about designs we could have in a future release. &lt;/p&gt;  &lt;h2&gt;Current Approach&lt;/h2&gt;  &lt;p&gt;Currently, there are two things that we look for when we navigate up the model item tree.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Collections of Variables name Variables&lt;/li&gt;    &lt;li&gt;Variables injected by the use of ActivityAction&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;As we walk up the tree, we need to find these.&amp;#160; Let’s first consider the following workflow we will use for our tests:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;wd.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    Activities =&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            Activities = &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; ForEach&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                    Body = &lt;span class="kwrd"&gt;new&lt;/span&gt; ActivityAction&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                         Argument = &lt;span class="kwrd"&gt;new&lt;/span&gt; DelegateInArgument&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; { Name=&lt;span class="str"&gt;&amp;quot;foo&amp;quot;&lt;/span&gt; },&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                         Handler = &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                            &lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;                                Activities = &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;                                }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;                            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;                    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;                }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;});&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Line 13 is the only one that might look a little different here, I’ll eventually have a post up about &lt;a href="http://msdn.microsoft.com/en-us/library/dd485397(VS.100).aspx"&gt;ActivityAction&lt;/a&gt; that talks in more detail what’s going on there.&lt;/p&gt;

&lt;p&gt;So, this loaded in a rehosted designer looks like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_thumb_2.png" width="234" height="373" /&gt;&lt;/a&gt;&amp;#160;&amp;#160; &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s look at the code to figure out what is in scope of the selected element.&amp;#160; First, let’s get the selected element :-) &lt;/p&gt;

&lt;pre class="csharpcode"&gt; Selection  sel = wd.Context.Items.GetValue&amp;lt;Selection&amp;gt;();
 &lt;span class="kwrd"&gt;if&lt;/span&gt; (sel != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
 {
        ModelItem mi = sel.PrimarySelection;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;mi is now the model item of my selected item.&amp;#160; Let’s write some code to walk up the tree and add to a collection called variables&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;while&lt;/span&gt; (mi.Parent != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    Type parentType = mi.Parent.ItemType;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Activity).IsAssignableFrom(parentType))&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="rem"&gt;// we have encountered an activity derived type&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="rem"&gt;// look for variable collection&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        ModelProperty mp = mi.Parent.Properties[&lt;span class="str"&gt;&amp;quot;Variables&amp;quot;&lt;/span&gt;];&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != mp &amp;amp;&amp;amp; mp.PropertyType == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Collection&amp;lt;Variable&amp;gt;))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            mp.Collection.ToList().ForEach(item =&amp;gt; variables.Add(item));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="rem"&gt;// now we need to look action handlers &lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    &lt;span class="rem"&gt;// this will ideally return a bunch of DelegateArguments&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    var dels = mi.Properties.Where(p =&amp;gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ActivityDelegate).IsAssignableFrom(p.PropertyType));&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var actdel &lt;span class="kwrd"&gt;in&lt;/span&gt; dels)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (actdel.Value != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var innerProp &lt;span class="kwrd"&gt;in&lt;/span&gt; actdel.Value.Properties)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DelegateArgument).IsAssignableFrom(innerProp.PropertyType) &amp;amp;&amp;amp; &lt;span class="kwrd"&gt;null&lt;/span&gt; != innerProp.Value)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                    variables.Add(innerProp.Value);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;                }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;    mi = mi.Parent;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Lines 4-13 handle the case where I just encounter an activity.&amp;#160; Lines 16-29 handle the slightly more tricky case where I need to handle ActivityAction (which ultimately derives from ActivityDelegate).&amp;#160; There are a few loops there but basically I look through all of the properties of the item which inherit from ActivityDelegate.&amp;#160; For each one of those, and for each property on that, I look for properties assignable from &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.delegateargument(VS.100).aspx"&gt;DelegateArgument&lt;/a&gt;.&amp;#160; As I find them I add them to my collection of model items for variables.&amp;#160; &lt;/p&gt;

&lt;p&gt;In my WPF app, I have a simple list box that shows all of these.&amp;#160; Because of the loosely typed data template I use in my WPF app, I get a pretty decent display since they share common things like &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.itemtype(VS.100).aspx"&gt;ItemType&lt;/a&gt; from ModelItem, and a &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.name(VS.100).aspx"&gt;Name&lt;/a&gt; that routes through to the underlying Name property both elements share. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/FindingtheVariablesinScopeWithintheWFDes_13A44/image_thumb_3.png" width="438" height="116" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ListBox&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;listBox1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Row&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;ColumnSpan&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;Column&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Horizontal&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Foo:&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;FontWeight&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Bold&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{Binding Path=ItemType}&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{Binding Path=Name}&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ListBox.ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ListBox&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h2&gt;Potential Future Approach&lt;/h2&gt;

&lt;p&gt;Our approach outlined above is generally correct.&amp;#160; That said, you can imagine a deeply nested data structure on an activity that contain variables that get injected into the scope at runtime.&amp;#160; We need a way for an activity to provide a way to declare how to get all of its variables.&amp;#160; The current approach is one of inspection, which works for all of our activities. In the future we may need to add an extensibility point to allow an activity author to specify how to find the variables that are available to its children.&amp;#160; The way that we could do that is to introduce an “VariableResolver” attribute which points to a type (or maybe a Func&amp;lt;&amp;gt;) that operates on the activity and returns the list of variables.&amp;#160; Actually today you could likely introduce a custom type descriptor that lifted the variables out of the activity and surfaces them in such a way that they would be discovered by the inspection above.&amp;#160; &lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Disclaimer: the Potential Future Approach is simply something that we’ve discussed that we could do, it does not represent something that we will do.&amp;#160; If you think that is an interesting extensibility point that you might want to take advantage of down the road, let me know.&amp;#160; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918399" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/p1HoDIkfX54" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="activities" scheme="http://blogs.msdn.com/mwinkle/archive/tags/activities/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><category term="vs2010" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/11/06/finding-the-variables-in-scope-within-the-wf-designer.aspx</feedburner:origLink></entry><entry><title>WF4 Beta1 =&gt; Beta2 Breaking Changes Document Published</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/rhG876ra2rA/wf4-beta1-beta2-breaking-changes-document-published.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/11/02/wf4-beta1-beta2-breaking-changes-document-published.aspx</id><published>2009-11-02T05:24:44Z</published><updated>2009-11-02T05:24:44Z</updated><content type="html">&lt;p&gt;Fresh on microsoft.com downloads, you can get the details of the major breaking changes that occurred for WF between Beta 1 and Beta 2.&lt;/p&gt;  &lt;p&gt;Get the document &lt;a href="http://bit.ly/1EsOVK"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;We will publish a similar document for any changes between Beta2 and RTM, although that list should be on the shorter side.&amp;#160; If you have feedback on the document, like the way something is presented or think we could have done a better job explaining it, please let me know.&amp;#160; Either comment here or use the &lt;a href="http://blogs.msdn.com/mwinkle/contact.aspx"&gt;“Email” link&lt;/a&gt; on the side. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916032" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/rhG876ra2rA" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><category term="vs2010" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/11/02/wf4-beta1-beta2-breaking-changes-document-published.aspx</feedburner:origLink></entry><entry><title>Deep Dive into the WF4 Designer Data Model: ModelItem and ModelProperty</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/1o4VpFakDx4/deep-dive-into-the-designer-data-model-modelitem-and-modelproperty.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/10/28/deep-dive-into-the-designer-data-model-modelitem-and-modelproperty.aspx</id><published>2009-10-28T21:50:45Z</published><updated>2009-10-28T21:50:45Z</updated><content type="html">&lt;p&gt;In this &lt;a href="http://blogs.msdn.com/mwinkle/archive/2009/06/17/introduction-to-wf-designer-rehosting-part-1.aspx"&gt;post&lt;/a&gt; I published an overview of the designer architecture.&amp;#160; I’ll copy the picture and the description of what I want to talk about today.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DeepDiveintotheDesignerDataModelModelIte_C3C6/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DeepDiveintotheDesignerDataModelModelIte_C3C6/image_thumb.png" width="417" height="192" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;There are a few key components here&lt;/p&gt;    &lt;ul&gt;     &lt;li&gt;Source        &lt;ul&gt;         &lt;li&gt;In VS, this is xaml, but this represents the durable storage of the “thing” we are editing &lt;/li&gt;       &lt;/ul&gt;     &lt;/li&gt;      &lt;li&gt;Instance        &lt;ul&gt;         &lt;li&gt;This is the in memory representation of the item being edited.&amp;#160; In vs2010 for the WF designer, this is a hierarchy of System.Activities instances (an object tree) &lt;/li&gt;       &lt;/ul&gt;     &lt;/li&gt;      &lt;li&gt;&lt;strong&gt;Model Item Tree &lt;/strong&gt;        &lt;ul&gt;         &lt;li&gt;&lt;strong&gt;This serves as an intermediary between the view and the instance, and is responsible for change notification and tracking things like undo state &lt;/strong&gt;&lt;/li&gt;       &lt;/ul&gt;     &lt;/li&gt;      &lt;li&gt;Design View        &lt;ul&gt;         &lt;li&gt;This is the visual editing view that is surfaced to the user, the designers are written using WPF, which uses plain old data binding in order to wire up to the underlying model items (which represent the data being edited). &lt;/li&gt;       &lt;/ul&gt;     &lt;/li&gt;      &lt;li&gt;Metadata Store        &lt;ul&gt;         &lt;li&gt;This is a mapping between type and designers, an attribute table for lack of a better term.&amp;#160; This is how we know what designer to use for what type &lt;/li&gt;       &lt;/ul&gt;     &lt;/li&gt;   &lt;/ul&gt; &lt;/blockquote&gt;  &lt;h1&gt;Motivating the ModelItem tree&lt;/h1&gt;  &lt;p&gt;One observation that you could make when looking at the diagram above is “I should just be able to bind the view to the instance.”&amp;#160; This approach could work, but has a couple of implementation problems:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;It is unrealistic to expect that instances of runtime types will all be built to fit perfectly into a design oriented world.&amp;#160; The most obvious problem is that our activity types aren’t going to inherit from &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyobject%28VS.100%29.aspx"&gt;DependencyObject&lt;/a&gt;, or implement &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged%28VS.100%29.aspx"&gt;INotifyPropertyChanged&lt;/a&gt;.&amp;#160; We can’t specify that all collections are &lt;a href="http://msdn.microsoft.com/en-us/library/ms668604.aspx"&gt;ObservableCollection&lt;/a&gt;&amp;#160; [interesting trivia, ObservableCollection has moved from WindowsBase.dll into System.dll].&amp;#160; If we could, that would make life easy, but that’s not the case.&amp;#160;&amp;#160; &lt;ul&gt;       &lt;li&gt;Additionally, there are design time services that we need to think about supporting (such as Undo/Redo), and we need to make sure we can consistently handle this across many object types, including those that have not been written by us. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;There may be a case for not actually operating on a live instance of the object graph.&amp;#160; Note, in VS2010, we do, but if we want to do work that would enable a design time XAML experience, we would need our instance to actually contain a lot of information about the source document.&amp;#160; &lt;/li&gt;    &lt;li&gt;If we go directly from the view to the instance, we tightly couple the two together, and that makes doing more interesting things in the future tricky.&amp;#160; For instance, if we want to add refactoring support to update instances of objects, we need more than just the object graph to do that (the model item tree also keeps track of things like back pointers, so I know everybody that references the object).&amp;#160; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;These reasons cause us to think about an abstraction we can use to intermediate the implementation details of the instance and the view with a common layer.&amp;#160; If you have programmed at the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model%28VS.100%29.aspx"&gt;WPF designer extensibility level&lt;/a&gt;, you will likely be familiar with the idea (and some of the types) here. &lt;/p&gt;  &lt;h1&gt;The ModelItem tree&lt;/h1&gt;  &lt;p&gt;The way that I think about the &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem%28VS.100%29.aspx"&gt;ModelItem&lt;/a&gt;/&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty%28VS.100%29.aspx"&gt;ModelProperty&lt;/a&gt; tree is that it forms a very thing proxy layer on top of the shape of the instance being edited.&amp;#160; &lt;/p&gt;  &lt;p&gt;Let’s start with a very simple type:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Animal
{
    &lt;span class="rem"&gt;// simple property&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="rem"&gt;// complex property &lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Location Residence { get; set; } 
    &lt;span class="rem"&gt;// list &lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;Animal&amp;gt; CloseRelatives { get; set; }
    &lt;span class="rem"&gt;// dictionary&lt;/span&gt;
    &lt;span class="kwrd"&gt;public&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; Features { get; set; } 
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Location
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; StreetAddress { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; City { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; State { get; set; } 
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Ignore for a moment that I just gave an animal Features, I’m a PM, it’s how we think :-) &lt;/p&gt;

&lt;p&gt;Now, let’s create some instances of that, and then actually create a ModelItem.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;EditingContext ec = &lt;span class="kwrd"&gt;new&lt;/span&gt; EditingContext();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;var companion1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Animal { Name = &lt;span class="str"&gt;&amp;quot;Houdini the parakeet&amp;quot;&lt;/span&gt; };&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;var companion2 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Animal { Name = &lt;span class="str"&gt;&amp;quot;Groucho the fish&amp;quot;&lt;/span&gt; };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;var animal = &lt;span class="kwrd"&gt;new&lt;/span&gt; Animal &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                 {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                     Name = &lt;span class="str"&gt;&amp;quot;Sasha the pug&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                     Residence = &lt;span class="kwrd"&gt;new&lt;/span&gt; Location &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                     {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                         StreetAddress = &lt;span class="str"&gt;&amp;quot;123 Main Street&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                         City = &lt;span class="str"&gt;&amp;quot;AnyTown&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                         State = &lt;span class="str"&gt;&amp;quot;Washington&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                     },&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                     Features = { &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                        {&lt;span class="str"&gt;&amp;quot;noise&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;snort&amp;quot;&lt;/span&gt; },&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                        {&lt;span class="str"&gt;&amp;quot;MeanTimeUntilNaps&amp;quot;&lt;/span&gt;, TimeSpan.FromMinutes(15) }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                     },&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;                     CloseRelatives = { companion1, companion2 } &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                 };&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;ModelTreeManager mtm = &lt;span class="kwrd"&gt;new&lt;/span&gt; ModelTreeManager(ec);&amp;#160; mtm.Load(animal);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;ModelItem mi = mtm.Root;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;One thing to note here is that I am using &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modeltreemanager%28VS.100%29.aspx"&gt;ModelTreeManager&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.editingcontext%28VS.100%29.aspx"&gt;EditingContext&lt;/a&gt; outside the context (no pun intended) of the designer (see lines 1, 19, and 20 in the above snippet).&amp;#160; This isn’t the usual way we interact with these, but it’s for this sample so that we can focus just on the data structure itself. [as an aside, my brother did have a parakeet named Houdini].&amp;#160; &lt;/p&gt;

&lt;p&gt;Let’s take a quick look at a visualization of what the data structure will look like.&amp;#160; Remember to think about the ModelItem tree as a thin proxy to the shape of the instance.&lt;/p&gt;

&lt;p&gt;Rather than spend an hour in powerpoint,&amp;#160; I’ll just include a sketch :-)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DeepDiveintotheDesignerDataModelModelIte_C3C6/IMAG0111_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="IMAG0111" border="0" alt="IMAG0111" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DeepDiveintotheDesignerDataModelModelIte_C3C6/IMAG0111_thumb.jpg" width="542" height="421" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;On the left, you see the object itself.&amp;#160; For that object, there will be one ModelItem which “points” to that object.&amp;#160; You can call &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.getcurrentvalue(VS.100).aspx"&gt;ModelItem.GetCurrentValue()&lt;/a&gt; and that will return the actual object. If you look at the ModelItem type, you will see some interesting properties which describe the object. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&amp;#160;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.itemtype(VS.100).aspx"&gt;ItemType&lt;/a&gt; is the type of the object pointed to (in this case, Animal) &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.parent(VS.100).aspx"&gt;Parent&lt;/a&gt; is the item in the tree which “owns” this model item (in the case of the root, this is null) &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.source(VS.100).aspx"&gt;Source&lt;/a&gt; is the property that provided the value (in the case of the root, this is null) &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.sources(VS.100).aspx"&gt;Sources&lt;/a&gt; is a collection of all the backpointers to all of the properties which hold this value 

    &lt;ul&gt;
      &lt;li&gt;Note, the distinction between Source and Sources and Parent and Parents is a topic worthy of another post &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.view(VS.100).aspx"&gt;View&lt;/a&gt; is the DependencyObject that is the visual (in teh case above, this is null as there is no view service hooked into the editing context) &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelitem.properties(VS.100).aspx"&gt;Properties&lt;/a&gt; is the collection of properties of this object &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Properties is the part where things get interesting.&amp;#160; There is a collection of ModelProperty objects which correspond to the shape of the underlying objects.&amp;#160; For the example above, let’s break in the debugger and see what there is to see. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DeepDiveintotheDesignerDataModelModelIte_C3C6/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/DeepDiveintotheDesignerDataModelModelIte_C3C6/image_thumb_1.png" width="711" height="515" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As we might expect, there are 4 properties, and you will see all sorts of properties that describe the properties.&amp;#160; A few interesting ones:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.computedvalue(VS.100).aspx"&gt;ComputedValue&lt;/a&gt;&amp;#160; is a short circuit to the return the underlying object that is pointed to by the property.&amp;#160; This is equivalent to ModelProperty.Value.GetCurrentValue(), but has an interesting side effect that setting it is equivalent to &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.setvalue(VS.100).aspx"&gt;SetValue().&lt;/a&gt;&amp;#160;&amp;#160; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.name(VS.100).aspx"&gt;Name&lt;/a&gt;, not surprisingly, this is name of the property &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.propertytype(VS.100).aspx"&gt;PropertyType&lt;/a&gt; is the type of the property &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.collection(VS.100).aspx"&gt;Collection&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.dictionary(VS.100).aspx"&gt;Dictionary&lt;/a&gt; are interesting little shortcuts that we’ll learn about in a future blog post. &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.value(VS.100).aspx"&gt;Value&lt;/a&gt; points to a model item that is in turn the pointer to the value &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.modelproperty.parent(VS.100).aspx"&gt;Parent&lt;/a&gt; points to the ModelItem which “owns” this property &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As Value points to another model item, you can see how this begins to wrap the object, and how this can be used to program against the data model.&amp;#160; Let’s look at a little bit of code.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;root.Properties[&lt;span class="str"&gt;&amp;quot;Residence&amp;quot;&lt;/span&gt;].
                Value.
                Properties[&lt;span class="str"&gt;&amp;quot;StreetAddress&amp;quot;&lt;/span&gt;].
                Value.GetCurrentValue()&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;You might say “hey, that’s a little ugly”&amp;#160; and I have two bits of good news for you.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;ModelItem has a custom type descriptor, which means that in WPF XAML we can bind in the way we expect (that is, I can bind to ModelItem.Location.StreetAddress, and the WPF binding mechanism will route that to mi.Properties[“Location”].Value.Properties[“StreetAddress”].&amp;#160; So, if you don’t use C# (and just use XAML), you don’t worry about this &lt;/li&gt;

  &lt;li&gt;In RTM, we will likely add support for the dynamic keyword in C# that will let you have a dynamic object and then program against it just like you would from WPF XAML.&amp;#160; It’s pretty cool and I hope we get to it, if we do I will blog about it. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s a set of tests which show the different things we’ve talked about:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;ModelItem root = mtm.Root;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;Assert.IsTrue(root.GetCurrentValue() == animal, &lt;span class="str"&gt;&amp;quot;GetCurrentValue() returns same object&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;Assert.IsTrue(root.ItemType == &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Animal),&lt;span class="str"&gt;&amp;quot;ItemType describes the item&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;Assert.IsTrue(root.Parent == &lt;span class="kwrd"&gt;null&lt;/span&gt;,&lt;span class="str"&gt;&amp;quot;root parent is null&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;Assert.IsTrue(root.Source == &lt;span class="kwrd"&gt;null&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;root source is null&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;Assert.IsTrue(((List&amp;lt;Animal&amp;gt;)root.Properties[&lt;span class="str"&gt;&amp;quot;CloseRelatives&amp;quot;&lt;/span&gt;].ComputedValue)[0] == companion1, &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;           &lt;span class="str"&gt;&amp;quot;ComputedValue of prop == actual object&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;Assert.IsFalse(((List&amp;lt;Animal&amp;gt;)root.Properties[&lt;span class="str"&gt;&amp;quot;CloseRelatives&amp;quot;&lt;/span&gt;].ComputedValue)[0] == companion2, &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;           &lt;span class="str"&gt;&amp;quot;ComputedValue of prop == actual object&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;Assert.AreEqual(root.Properties[&lt;span class="str"&gt;&amp;quot;Residence&amp;quot;&lt;/span&gt;].&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    Value.&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    Properties[&lt;span class="str"&gt;&amp;quot;StreetAddress&amp;quot;&lt;/span&gt;].&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    Value.GetCurrentValue(), &lt;span class="str"&gt;&amp;quot;123 Main Street&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;get actual value back out&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;Assert.AreEqual(root, root.Properties[&lt;span class="str"&gt;&amp;quot;Residence&amp;quot;&lt;/span&gt;].Parent, &lt;span class="str"&gt;&amp;quot;property points to owner&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;ModelItem location = root.Properties[&lt;span class="str"&gt;&amp;quot;Residence&amp;quot;&lt;/span&gt;].Value;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;Assert.AreEqual(root.Properties[&lt;span class="str"&gt;&amp;quot;Residence&amp;quot;&lt;/span&gt;], location.Source, &lt;span class="str"&gt;&amp;quot;sources point to the right place&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;h2&gt;Oh my, won’t this get explosively large?&lt;/h2&gt;

&lt;p&gt;Good question, and the truth is that yes, this could get large as you were to spelunk the object graph.&amp;#160; The good news is that we’re incredibly lazy about loading this, we will only flush out the properties collection on demand, and we won’t generate a ModelItem until it is requested.&amp;#160; When we combine this with the View virtualization work we have done, we will only ever load as much in the WF designer as you need.&amp;#160;&amp;#160; This keeps the overhead minimal, and in does not represent a substantial memory overhead.&lt;/p&gt;

&lt;h1&gt;Why should I be careful about ModelItem.GetCurrentValue()&lt;/h1&gt;

&lt;p&gt;One might be tempted to just say “Hey, I’m in C#, I’ll just call GetCurrentValue() and party on that.&amp;#160; If you do that, you are entering dangerous waters where you can mess up the data model.&amp;#160; Since the underlying instance doesn’t likely support any change notification mechanism, the model item tree will get out of sync with the underlying instance description.&amp;#160; This will manifest itself in problems at the designer because our serialization is based off the instance, not the ModelItem tree (note, that’s a vs2010 implementation detail that could change in a subsequent release).&amp;#160; The net result though is that you will get your view out of sync with your instance and serialization and that’s generally considered problematic.&amp;#160; &lt;/p&gt;

&lt;h1&gt;Summary&lt;/h1&gt;

&lt;p&gt;Wow, that’s a longer post than I intended.&amp;#160; What have we covered:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Modelitem tree and why we need it &lt;/li&gt;

  &lt;li&gt;The relationship between the underlying instance and ModelItem/ModelProperty &lt;/li&gt;

  &lt;li&gt;The shape and use of ModelItem / ModelProperty &lt;/li&gt;

  &lt;li&gt;Imperative programming against the tree &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What haven’t we covered yet&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;ModelItemCollection and ModelItemDictionary &lt;/li&gt;

  &lt;li&gt;How to use Sources and Parents to understand how the object sits in the graph and manipulation we can do for fun and profit &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ll get there.&amp;#160; In the meantime, if you have questions, let me know. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;**** Minor update on 10/29 to fix a bug in the code ****&lt;/p&gt;

&lt;p&gt;This is the way to use ModelTreeManager to generate ModelItems (Line 3 is the critical piece that was missing):&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;EditingContext ec = &lt;span class="kwrd"&gt;new&lt;/span&gt; EditingContext();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;ModelTreeManager mtm = &lt;span class="kwrd"&gt;new&lt;/span&gt; ModelTreeManager(ec);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;strong&gt;mtm.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence());&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;mtm.Root.Properties[&lt;span class="str"&gt;&amp;quot;Activities&amp;quot;&lt;/span&gt;].Collection.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine());&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914364" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/1o4VpFakDx4" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/10/28/deep-dive-into-the-designer-data-model-modelitem-and-modelproperty.aspx</feedburner:origLink></entry><entry><title>WF4 Designer Bloggers</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/-NEsYidTY98/wf4-designer-bloggers.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/10/28/wf4-designer-bloggers.aspx</id><published>2009-10-28T17:29:52Z</published><updated>2009-10-28T17:29:52Z</updated><content type="html">&lt;p&gt;I wanted to put a quick note up as the team is starting to blog a little more frequently and putting some interesting content out there.&amp;#160; A few places to check out to hear from the folks on the team&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint"&gt;Endpoint&lt;/a&gt; – This is the general WF team blog, and has had some good posts &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint/archive/2009/10/26/going-to-pdc-want-to-meet-the-team.aspx"&gt;Going to PDC? Want to Meet the Team?&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint/archive/2009/10/21/client-profile-in-net-4.aspx"&gt;Client Profile in .NET 4&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint/archive/2009/10/20/wf4-changes-between-beta-1-and-beta-2.aspx"&gt;WF4 Changes between Beta1 and Beta2&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/cathyk"&gt;Cathy Dumas&lt;/a&gt; – Cathy is the PM on my team focused on the expression editing experience and the designer UX&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://blogs.msdn.com/cathyk/archive/2009/10/27/vb-expression-example-manipulating-generic-lists.aspx"&gt;VB Expressions Example: Manipulating Generic Lists&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="VB for C# Developers"&gt;VB for C# developers&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/kushals"&gt;Kushal Shah&lt;/a&gt; – Kushal is the PM on my team for debugging and Visual Studio integration&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://blogs.msdn.com/kushals/archive/2009/10/27/adding-activities-on-the-designer-programmatically.aspx"&gt;Adding Activities on the designer programmatically&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="http://blogs.msdn.com/kushals/archive/2009/10/26/adding-variables-expressions-and-bindings-programmatically.aspx"&gt;Adding Variables, Expressions and Bindings Programmatically&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="WF 4.0 Templates - Beta2"&gt;WF4 Templates – Beta 2&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;What blogs are you reading for WF4 content?&amp;#160; What kind of stuff would you like to hear more about?&amp;#160; Let us know!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914205" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/-NEsYidTY98" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="vs2010" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/10/28/wf4-designer-bloggers.aspx</feedburner:origLink></entry><entry><title>Types, Metatypes and Bears, Redux</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/KuFSpUpe5AE/types-metatypes-and-bears-redux.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/10/23/types-metatypes-and-bears-redux.aspx</id><published>2009-10-23T16:16:29Z</published><updated>2009-10-23T16:16:29Z</updated><content type="html">&lt;p&gt;I made a quick &lt;a href="http://blogs.msdn.com/mwinkle/archive/2009/06/10/types-metatypes-and-bears-oh-my.aspx"&gt;post a few months back&lt;/a&gt; where I tried to talk about the way the designer works and lets us design types, as well as simply configure instances of types.&lt;/p&gt;  &lt;p&gt;There were a couple of key points that I wanted to make there in that post:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The workflow designer can configure instances of activity graphs, &lt;em&gt;and&lt;/em&gt; create entire types as well &lt;/li&gt;    &lt;li&gt;Types are designed by editing an instance of a type that represents the type being designed, the metatype &lt;/li&gt;    &lt;li&gt;There is some XAML trickery required to serialize and deserialize this &lt;/li&gt;    &lt;li&gt;This same type of work is done to enable the &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.dynamicactivity%28VS.100%29.aspx"&gt;DynamicActivity&lt;/a&gt; capability &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;A few folks have noticed (and sent me mail), that things look a little different in Beta2.&amp;#160; While we are going to have a more thorough, “here’s everything that changed” doc, I want to go ahead and update at least some of the things that I’ve been talking about here.&lt;/p&gt;  &lt;h1&gt;What’s New&lt;/h1&gt;  &lt;p&gt;In reality, very little is new, we’ve primarily moved stuff around now.&amp;#160; One thing that you may remember is that the DesignTimeXamlReader was not public in beta1, and if you are looking around, you may not find it.&amp;#160; We have made this functionality public however.&amp;#160; Thus, see the “what’s changed&amp;quot; bit.&lt;/p&gt;  &lt;h1&gt;What’s Changed&lt;/h1&gt;  &lt;p&gt;We took a long look at things and realized we had a bunch of XAML stuff all over the place.&amp;#160; We felt it would be a good idea to try to consolidate that into one place in WF, so &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices(VS.100).aspx"&gt;System.Activities.XamlIntegration.ActivityXamlServices&lt;/a&gt; becomes your one stop shop for most things Activity and XAML related.&amp;#160; Let’s take a quick look and see what’s in there:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;ActivityXamlServices Members&lt;/p&gt;    &lt;p&gt;[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]&lt;/p&gt;    &lt;p&gt;Creates an instance of an activity tree described in XAML.&lt;/p&gt;    &lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices%28VS.100%29.aspx"&gt;ActivityXamlServices&lt;/a&gt; type exposes the following members.&lt;/p&gt;    &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image001%5B4%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001[4]" border="0" alt="clip_image001[4]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image001%5B4%5D_thumb.gif" width="1" height="1" /&gt;&lt;/a&gt; Methods       &lt;table border="1" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;         &lt;tr&gt;           &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B10%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002[10]" border="0" alt="clip_image002[10]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B10%5D_thumb.gif" width="16" height="11" /&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B10%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003[10]" border="0" alt="clip_image003[10]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B10%5D_thumb.gif" width="13" height="10" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderreader%28VS.100%29.aspx"&gt;CreateBuilderReader&lt;/a&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;Overloaded. Maps an x:Class activity tree to an &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.activitybuilder%28VS.100%29.aspx"&gt;ActivityBuilder&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/ee149744%28VS.100%29.aspx"&gt;ActivityBuilder&amp;lt;(Of &amp;lt;(TResult&amp;gt;)&amp;gt;)&lt;/a&gt;.&lt;/p&gt;           &lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B11%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002[11]" border="0" alt="clip_image002[11]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B11%5D_thumb.gif" width="16" height="11" /&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B11%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003[11]" border="0" alt="clip_image003[11]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B11%5D_thumb.gif" width="13" height="10" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderwriter%28VS.100%29.aspx"&gt;CreateBuilderWriter&lt;/a&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;Maps an &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.activitybuilder%28VS.100%29.aspx"&gt;ActivityBuilder&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/ee149744%28VS.100%29.aspx"&gt;ActivityBuilder&amp;lt;(Of &amp;lt;(TResult&amp;gt;)&amp;gt;)&lt;/a&gt; from the specified writer to an x:Class activity tree.&lt;/p&gt;           &lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B12%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002[12]" border="0" alt="clip_image002[12]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B12%5D_thumb.gif" width="16" height="11" /&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B12%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003[12]" border="0" alt="clip_image003[12]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B12%5D_thumb.gif" width="13" height="10" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createreader%28VS.100%29.aspx"&gt;CreateReader&lt;/a&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;Overloaded. Maps an x:Class activity tree to an &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.dynamicactivity%28VS.100%29.aspx"&gt;DynamicActivity&lt;/a&gt; or &lt;a href="http://msdn.microsoft.com/en-us/library/dd465645%28VS.100%29.aspx"&gt;DynamicActivity&amp;lt;(Of &amp;lt;(TResult&amp;gt;)&amp;gt;)&lt;/a&gt;.&lt;/p&gt;           &lt;/td&gt;         &lt;/tr&gt;          &lt;tr&gt;           &lt;td valign="top"&gt;             &lt;p&gt;&lt;b&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B13%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002[13]" border="0" alt="clip_image002[13]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image002%5B13%5D_thumb.gif" width="16" height="11" /&gt;&lt;/a&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B13%5D.gif"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003[13]" border="0" alt="clip_image003[13]" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/TypesMetatypesandBearsRedux_13C27/clip_image003%5B13%5D_thumb.gif" width="13" height="10" /&gt;&lt;/a&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.load%28VS.100%29.aspx"&gt;Load&lt;/a&gt;&lt;/p&gt;           &lt;/td&gt;            &lt;td valign="top"&gt;             &lt;p&gt;Overloaded. Creates an instance of a declarative workflow.&lt;/p&gt;           &lt;/td&gt;         &lt;/tr&gt;       &lt;/tbody&gt;&lt;/table&gt;   &lt;/p&gt;    &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices_members%28VS.100%29.aspx#mainBody"&gt;Top&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.load%28VS.100%29.aspx"&gt;Load&lt;/a&gt; is used to generally take some XAML and return an Activity which you can then use to execute.&amp;#160; If Load encounters a XAML stream for &amp;lt;Activity x:Class, it will subsequently generate a DynamicActivity.&amp;#160; This functions basically the same way WorkflowXamlServices.Load() did in beta1.&amp;#160; &lt;/p&gt;  &lt;p&gt;You also see &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderreader(VS.100).aspx"&gt;CreateBuilderReader&lt;/a&gt;, and &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderwriter(VS.100).aspx"&gt;CreateBuilderWriter&lt;/a&gt;, which are used to surface the DesignTimeXaml capabilities that we used in beta1.&amp;#160; These will return an instance of a XamlReader/Writer that handles the transformation between the metatype and the &amp;lt;Activity x:Class XAML.&amp;#160;&amp;#160; The metatype has changed names from ActivitySchemaType to &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderreader(VS.100).aspx"&gt;ActivityBuilder&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The table below should help summarize the uses and changes between beta1 and beta2.&amp;#160; In this area, I don’t expect any changes between what you see now, and what you will see in RTM.&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="491"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="133"&gt;         &lt;p align="center"&gt;&lt;strong&gt;Task&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="178"&gt;         &lt;p align="center"&gt;&lt;strong&gt;Beta1&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="178"&gt;         &lt;p align="center"&gt;&lt;strong&gt;Beta2&lt;/strong&gt;&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;metatype (type to build types)&lt;/td&gt;        &lt;td valign="top" width="178"&gt;ActivitySchemaType&lt;/td&gt;        &lt;td valign="top" width="178"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.activitybuilder%28VS.100%29.aspx"&gt;ActivityBuilder&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Mechanism to load DynamicActivity&lt;/td&gt;        &lt;td valign="top" width="178"&gt;WorkflowXamlServices.Load()&lt;/td&gt;        &lt;td valign="top" width="178"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.load%28VS.100%29.aspx"&gt;ActivityXamlServices.Load()&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Mechanism to load ActivityBuilder&lt;/td&gt;        &lt;td valign="top" width="178"&gt;use WorkflowDesigner.Load() to get an ActivitySchemaType&lt;/td&gt;        &lt;td valign="top" width="178"&gt;Use the reader from &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderreader%28VS.100%29.aspx"&gt;CreateBuilderReader()&lt;/a&gt; to pass into &lt;a href="http://msdn.microsoft.com/en-us/library/system.xaml.xamlservices.load(VS.100).aspx"&gt;XamlServices.Load()&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;Mechanism to save ActivityBuilder to XAML&lt;/td&gt;        &lt;td valign="top" width="178"&gt;Create a new DesignTimeXamlWriter, pass that to XamlServices.Save()&lt;/td&gt;        &lt;td valign="top" width="178"&gt;Use the writer returned from CreateBuilderWriter() to pass into &lt;a href="http://msdn.microsoft.com/en-us/library/system.xaml.xamlservices.save(VS.100).aspx"&gt;XamlServices.Save()&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="133"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="178"&gt;&amp;#160;&lt;/td&gt;        &lt;td valign="top" width="178"&gt;&amp;#160;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;To explore this, use CreateBuilderReader() and XamlServices.Load() on a workflow that you’ve built in the designer and poke around a bit to see what’s going on. &lt;/p&gt;  &lt;p&gt;Here is some sample code that walks through this:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;ActivityBuilder ab1 = &lt;span class="kwrd"&gt;new&lt;/span&gt; ActivityBuilder();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;ab1.Name = &lt;span class="str"&gt;&amp;quot;helloWorld.Foo&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;ab1.Properties.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; DynamicActivityProperty { Name = &lt;span class="str"&gt;&amp;quot;input1&amp;quot;&lt;/span&gt;, Type = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(InArgument&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;) });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;ab1.Properties.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; DynamicActivityProperty { Name = &lt;span class="str"&gt;&amp;quot;input2&amp;quot;&lt;/span&gt;, Type = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(InArgument&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;) });&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;ab1.Properties.Add(&lt;span class="kwrd"&gt;new&lt;/span&gt; DynamicActivityProperty { Name = &lt;span class="str"&gt;&amp;quot;output&amp;quot;&lt;/span&gt;, Type = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(OutArgument&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;) });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;ab1.Implementation = &lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    Activities =&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine { Text = &lt;span class="str"&gt;&amp;quot;Getting Started &amp;quot;&lt;/span&gt; },&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; Delay { Duration = TimeSpan.FromSeconds(4) },&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine { Text = &lt;span class="kwrd"&gt;new&lt;/span&gt; VisualBasicValue&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; { ExpressionText= &lt;span class="str"&gt;&amp;quot;input1 + input2&amp;quot;&lt;/span&gt; }},&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; Assign&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; { To = &lt;span class="kwrd"&gt;new&lt;/span&gt; VisualBasicReference&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; { ExpressionText = &lt;span class="str"&gt;&amp;quot;output&amp;quot;&lt;/span&gt; },&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                     Value = &lt;span class="kwrd"&gt;new&lt;/span&gt; VisualBasicValue&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; {ExpressionText= &lt;span class="str"&gt;&amp;quot;input1 + input2 + \&amp;quot;that's it folks\&amp;quot;&amp;quot;&lt;/span&gt; } }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;StringBuilder sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;StringWriter tw = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringWriter(sb);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;XamlWriter xw = ActivityXamlServices.CreateBuilderWriter(&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    &lt;span class="kwrd"&gt;new&lt;/span&gt; XamlXmlWriter(tw, &lt;span class="kwrd"&gt;new&lt;/span&gt; XamlSchemaContext()));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;XamlServices.Save(xw , ab1);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; serializedAB = sb.ToString();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;DynamicActivity da2 = ActivityXamlServices.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; StringReader(serializedAB)) &lt;span class="kwrd"&gt;as&lt;/span&gt; DynamicActivity;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;var result = WorkflowInvoker.Invoke(da2, &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;,&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt; { {&lt;span class="str"&gt;&amp;quot;input1&amp;quot;&lt;/span&gt;,&lt;span class="str"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;}, {&lt;span class="str"&gt;&amp;quot;input2&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;world&amp;quot;&lt;/span&gt; }});&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;result text is {0}&amp;quot;&lt;/span&gt;, result[&lt;span class="str"&gt;&amp;quot;output&amp;quot;&lt;/span&gt;]);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;ActivityBuilder ab = XamlServices.Load(&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;    ActivityXamlServices.CreateBuilderReader(&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; XamlXmlReader(&lt;span class="kwrd"&gt;new&lt;/span&gt; StringReader(serializedAB)))) &lt;span class="kwrd"&gt;as&lt;/span&gt; ActivityBuilder;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;there are {0} arguments in the activity builder&amp;quot;&lt;/span&gt;, ab.Properties.Count);&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press enter to exit&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;Console.ReadLine();&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Good luck, and happy metatyping!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912121" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/KuFSpUpe5AE" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="Workflow" scheme="http://blogs.msdn.com/mwinkle/archive/tags/Workflow/default.aspx" /><category term="designer" scheme="http://blogs.msdn.com/mwinkle/archive/tags/designer/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><category term="xaml" scheme="http://blogs.msdn.com/mwinkle/archive/tags/xaml/default.aspx" /><category term="vs2010" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/10/23/types-metatypes-and-bears-redux.aspx</feedburner:origLink></entry><entry><title>Navigating the WF4 Beta 2 Samples</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/pwhL3I5DRwI/navigating-the-wf4-beta-2-samples.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/10/22/navigating-the-wf4-beta-2-samples.aspx</id><published>2009-10-22T19:25:04Z</published><updated>2009-10-22T19:25:04Z</updated><content type="html">&lt;p&gt;Hot off the presses (and the download center) come the WF4 Beta 2 samples &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=35ec8682-d5fd-4bc3-a51a-d8ad115a8792&amp;amp;displaylang=en"&gt;here&lt;/a&gt;.&amp;#160; The team has invested a lot of time into these samples and they provide a good way to get up to speed on the way a particular feature or group of features work together.&lt;/p&gt;  &lt;p&gt;Note, there are 2300 files to be unzipped, so hopefully there is a sample in here for everyone.&lt;/p&gt;  &lt;p&gt;At a high level, we work down the directory structure from technology, sample type, and then some functional grouping of samples.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/NavigatingtheWF4Beta2Samples_AE9C/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/NavigatingtheWF4Beta2Samples_AE9C/image_thumb.png" width="217" height="476" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Within the “Sample Type” we have a few different categories we use.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Basic &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;These are “one feature” samples that are used to illustrate how to use a given sample.&amp;#160; Often times they are hosted in the most basic wrapper necessary in order to get the feature to a point where it can be shown.&amp;#160; &lt;/li&gt;      &lt;li&gt;These are grouped within feature level areas, a few&amp;#160; examples from the samples are:&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;\WF\Basic&lt;/li&gt;        &lt;ul&gt;         &lt;li&gt;\BuiltInActivities – how to configure and use the activities that are in the box&lt;/li&gt;          &lt;li&gt;\CustomActivities&lt;/li&gt;          &lt;ul&gt;           &lt;li&gt;\CodeBodied\ – writing activities in code, including async, composite, and leveraging ActivityAction’s&lt;/li&gt;            &lt;li&gt;\Composite – writing composite activities&lt;/li&gt;            &lt;li&gt;\CustomActivityDesigners – writing activity designers&lt;/li&gt;         &lt;/ul&gt;          &lt;li&gt;\Designer – programming against the infrastructure, a tree view designer, and a XamlWriter which will remove view state.&lt;/li&gt;          &lt;li&gt;\Persistance&lt;/li&gt;          &lt;li&gt;\Tracking&lt;/li&gt;       &lt;/ul&gt;     &lt;/ul&gt;   &lt;/ul&gt;    &lt;li&gt;Scenario&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;These are higher level samples that require pulling together a number of features in order to highlight how the features can be combined to enable an application of the technology that might be of interest.&amp;#160; In the WF bucket, you will see things like Compensation and Services, which pull together a number of individual features&lt;/li&gt;      &lt;li&gt;The ActivityLibrary folder is chock full of interesting sample activities that are useful for seeing how to write activities, as well as code that might be useful in your application.&amp;#160; Some of these are items which we aren’t shipping in the framework but may in the future.&amp;#160;&amp;#160; Many of these also include interesting designers as well.&amp;#160; Some of the interesting sample activities in here:&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee661651(VS.100).aspx"&gt;CommentOut&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee622977(VS.100).aspx"&gt;DbActvities&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd797586(VS.100).aspx"&gt;Powershell&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd797582(VS.100).aspx"&gt;LinqToSql&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/library/dd797580(VS.100).aspx"&gt;LinqToObjects&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd797585(VS.100).aspx"&gt;SendMail&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee620808(VS.100).aspx"&gt;ThrottledParallelForEach&lt;/a&gt;&lt;/li&gt;     &lt;/ul&gt;   &lt;/ul&gt;    &lt;li&gt;Application&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;These samples are used to show how to pull everything together within the context of an application.&amp;#160; For instance, the &lt;a href="http://msdn.microsoft.com/en-us/library/ee624139(VS.100).aspx"&gt;WorkflowSimulator&lt;/a&gt; is described this way:&lt;/li&gt;      &lt;ul&gt;       &lt;p&gt;&lt;em&gt;This sample demonstrates how to write a workflow simulator that displays the running workflow graphically. The application executes a simple flowchart workflow (defined in Workflow.xaml) and re-hosts the workflow designer to display the currently executing workflow. As the workflow is executed, the currently executing activity is shown with a yellow outline and debug arrow. In addition tracking records generated by the workflow are also displayed in the application window. For more information about workflow tracking, see &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee513992(VS.100).aspx"&gt;&lt;em&gt;Workflow Tracking and Tracing&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. For more information about re-hosting the workflow designer, see &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd489451(VS.100).aspx"&gt;&lt;em&gt;Rehosting the Workflow Designer&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;        &lt;p&gt;&lt;em&gt;The workflow simulator works by keeping two dictionaries. One contains a mapping between the currently executing activity object and the XAML line number in which the activity is instantiated. The other contains a mapping between the activity instance ID and the activity object. When tracking records are emitted using a custom tracking profile, the application determines the instance ID of the currently executing activity and maps it back to the XAML file that instantiated it. The re-hosted workflow designer is then instructed to highlight the activity on the designer surface and use the same method as the workflow debugger, specifically drawing a yellow border around the activity and displaying a yellow arrow along the left side of the designer&lt;/em&gt;&lt;/p&gt;     &lt;/ul&gt;   &lt;/ul&gt;    &lt;li&gt;Extensibility&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;This is a section inside the WCF samples that focuses on the various mechanisms and levels of extensibility &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I will be blogging more on some of the interesting (to me) individual samples.&amp;#160; What do you think?&amp;#160; Are there samples you’d like to see?&amp;#160; How are you using these, is there anything we can do to make these more useful? &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911620" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/pwhL3I5DRwI" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="Workflow" scheme="http://blogs.msdn.com/mwinkle/archive/tags/Workflow/default.aspx" /><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><category term="vs2010" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/10/22/navigating-the-wf4-beta-2-samples.aspx</feedburner:origLink></entry><entry><title>WF4 Designer Enhancements in VS 2010 Beta 2</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/dalmJedAU0s/wf4-designer-enhancements-in-vs-2010-beta-2.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/10/20/wf4-designer-enhancements-in-vs-2010-beta-2.aspx</id><published>2009-10-20T17:10:24Z</published><updated>2009-10-20T17:10:24Z</updated><content type="html">&lt;p&gt;So, you might have heard that &lt;a href="http://go.microsoft.com/fwlink/?LinkID=151797"&gt;Beta2 has shipped&lt;/a&gt;.&amp;#160; I wanted to give a brief overview of the changes that have been made to the designer &lt;a href="http://blogs.msdn.com/mwinkle/archive/2009/05/20/introducing-the-wf4-designer.aspx"&gt;since beta1&lt;/a&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;So, without further ado, here are my top 10 new designer features in Beta 2&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;New UI &lt;/li&gt;    &lt;li&gt;Expand in place &lt;/li&gt;    &lt;li&gt;Choose Toolbox Items &lt;/li&gt;    &lt;li&gt;Imports designer &lt;/li&gt;    &lt;li&gt;Text on Flowchart labels &lt;/li&gt;    &lt;li&gt;IActivityTemplateFactory is public &lt;/li&gt;    &lt;li&gt;Namespace change &lt;/li&gt;    &lt;li&gt;WriteLine designer &lt;/li&gt;    &lt;li&gt;UI Virtualization &lt;/li&gt;    &lt;li&gt;Information about arguments in the property grid &lt;/li&gt; &lt;/ol&gt;  &lt;h1&gt;New UI&lt;/h1&gt;  &lt;p&gt;We made a decision in Beta2 to do a bit of an overhaul on the designers general theme and feel in order to feel more like part of VS.&amp;#160; The UI we had in Beta1 was still the first pass at the designer surface that we showed last year in the first CTP at PDC.&amp;#160; Here are some screenshots of that new UI.&amp;#160; Our UX PM, Cathy, has started a &lt;a href="http://blogs.msdn.com/cathyk/"&gt;blog&lt;/a&gt;, and I expect she will have some really interesting discussions about the design decisions that we made. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_24.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_11.png" width="647" height="424" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We’ve rounded out the set of icons as well &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_34.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_16.png" width="329" height="86" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_15.png" width="244" height="72" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;We’ve also created focus around the header, and surface information within that header (like validation errors)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_28.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_13.png" width="409" height="140" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h1&gt;Expand in Place&lt;/h1&gt;  &lt;p&gt;One of the biggest pieces of feedback that we got from the Beta1 release was the need to see what’s going on in my workflow.&amp;#160; The model we had in Beta1 was optimized around a few levels of composition, and required the user to double-click to drill into the activity.&amp;#160; This model works well to focus on an activity, but comes at the expense of the broader view.&amp;#160; We’ve gone ahead and changed that in beta2 that allows the workflow items to expand in place. &lt;/p&gt;  &lt;p&gt;I am jazzed that we did this, and there is no good way to put it in a picture.&amp;#160; Open up the designer and start playing around, and I think you’ll like what you’ll see.&amp;#160; The other nice part of this is that I can still choose to drill into if I want to have that focus.&amp;#160; This should also support fairly deep nesting of activities, meaning you can visualize large, complex workflows on the canvas.&amp;#160; &lt;/p&gt;  &lt;p&gt;Additionally, you can choose to expand or collapse individual nodes, or go to the “Expand All” command in order to expand out the tree.&amp;#160; One thing to note is that we don’t allow expansion inside of a flowchart because we don’t yet have a mechanism that lets me rearrange all of the items around that newly expanded activity.&amp;#160; &lt;/p&gt;  &lt;h1&gt;Choose Toolbox Items&lt;/h1&gt;  &lt;p&gt;If you have an assembly on disk somewhere that contains some activities, you can now add it into the toolbox through the Choose Items dialog.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_9.png" width="343" height="274" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_22.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_10.png" width="560" height="423" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When you drop these new items on the canvas, the appropriate reference should be wired up for you. &lt;/p&gt;  &lt;h1&gt;Imports Designer&lt;/h1&gt;  &lt;p&gt;One thing that we heard from folks is that they like the vb expressions (well, they like the expressions, they aren’t super excited that we only have one language choice at this point), but they really didn’t like fully qualifying the type names.&amp;#160; To help out with this, we’ve introduced the Imports designer which lets you pick out the namespaces you want to import that will be used to make it easier to resolve types.&lt;/p&gt;  &lt;p&gt;Before:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_6.png" width="366" height="146" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Go to the Imports designer down at the bottom (next to Arguments and Variables) and add System.Xml&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_16.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_7.png" width="348" height="310" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This will now bring in System.Xml into the expression text box:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_18.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_8.png" width="393" height="145" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;Text on Flowchart Labels&lt;/h1&gt;  &lt;p&gt;People seem to like the flowchart model, but one request we heard was that it was tough to see what all the lines meant, especially coming out of the branching constructs. I’ll show a few other interesting flowchart things here.&lt;/p&gt;  &lt;p&gt;First, hovering over a switch/decision will show the expression&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_3.png" width="244" height="186" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Clicking on the small triangle will “pin” this expression so that I can see it while working on the flowchart.&amp;#160; Now, hook up some of the lines:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_4.png" width="405" height="292" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We also heard that the labels True and False are descriptive for the decision, they may not capture the intent.&amp;#160; So, you can click on the decision, open the property grid and set these to some custom value.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_5.png" width="386" height="130" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Switch will display the switch values as well. &lt;/p&gt;  &lt;h1&gt;IActivityTemplateFactory is Public&lt;/h1&gt;  &lt;p&gt;Towards the end of Beta1, we slipped a little feature in called IActivityTemplateFactory as an internal API to generate a configured set of activities (like what happens when I drop the messaging activity pairs).&amp;#160; We found a number of folks really liked this idea, so we have made this public.&amp;#160; This lets you add these factories to the toolbox to drop a templatized, configured set of activities onto the canvas.&amp;#160; A real simple one would look like [this drops a Pick with two branches, like what happens today when you drop a Pick]:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; PickWithTwoBranchesFactory : IActivityTemplateFactory&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; Activity Create(DependencyObject target)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Pick&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            Branches =&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; PickBranch&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                    DisplayName = &lt;span class="str"&gt;&amp;quot;Branch1&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                },&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; PickBranch&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                {&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                    DisplayName = &lt;span class="str"&gt;&amp;quot;Branch2&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        };&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h1&gt;Namespace change&lt;/h1&gt;

&lt;p&gt;We’ve made some OM changes (there have been some I’ll blog about later). One important one is that we needed to move out of the *.Design namespaces, primarily because *.Design is meant to specifically imply VS designer specific stuff, and our designer stuff is not VS specific.&amp;#160; So, we’ve &lt;strong&gt;moved from .Design to .Presentation&lt;/strong&gt; as our namespace and assembly names of choice. There has also been some reduction in the number of namespaces, and moving some types out of the root namespace (System.Activities.Presentation) into more specialized namespaces (System.Activities.Presentation.Converters).&amp;#160; &lt;/p&gt;

&lt;p&gt;We’ve also reduced the number of assemblies from 3 to 2, and here is the way to think about them. &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;System.Activities.Presentation.dll =&amp;gt; this is the core extensibility mechanism and the bulk of the “guts” of the designer &lt;/li&gt;

  &lt;li&gt;System.Activities.Core.Presentation.dll =&amp;gt; this is primarily the assembly that contains the designers for the out of box activity designers.&amp;#160; There are some, but not too many extensibility / programmability points. 
    &lt;ul&gt;
      &lt;li&gt;One thing to note is that the out of box designers have been made internal as there isn’t any extensibility built into those. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Within System.Activities.Presentation.dll, here are the public namespaces:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;System.Activities.Presentation &lt;/li&gt;

  &lt;li&gt;.Converters &lt;/li&gt;

  &lt;li&gt;.Debug &lt;/li&gt;

  &lt;li&gt;.Hosting &lt;/li&gt;

  &lt;li&gt;.Metadata &lt;/li&gt;

  &lt;li&gt;.Model &lt;/li&gt;

  &lt;li&gt;.PropertyEditing &lt;/li&gt;

  &lt;li&gt;.Services &lt;/li&gt;

  &lt;li&gt;.Toolbox &lt;/li&gt;

  &lt;li&gt;.Validation &lt;/li&gt;

  &lt;li&gt;.View &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;&amp;#160;&lt;/h1&gt;

&lt;h1&gt;Writeline Designer&lt;/h1&gt;

&lt;p&gt;We had not originally planned for a designer for WriteLine, we had felt that the default designer was good enough for this.&amp;#160; We heard some feedback and one of the testers decided to put one together.&amp;#160; This makes it easy to configure the WriteLine on the canvas:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_2.png" width="343" height="204" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;UI Virtualization &lt;/h1&gt;

&lt;p&gt;This is a feature you may not see, or ever need to think about, but it’s one that I think is pretty neat, and helps us increase performance for large workflows.&amp;#160; We’ve built up some infrastructure inside the designer that supports virtualization of the UI surface.&amp;#160; The way to think about this is lazy loading the visuals of the designer until they are actually needed.&amp;#160; While this isn’t that useful for a small workflow, as a workflow starts to span multiple screens, it makes sense to only load the visual elements that are required for the workflow that are actually in view.&amp;#160; You may see artifacts of this if you open a large workflow as you see some of the workflow “draw on the fly.”&amp;#160; The advantages of doing this are that bigger workflows will open faster with fewer visual elements on the screen.&amp;#160; The information used by virtualization is coupled with the viewstate of the workflow in order to cache the size of the elements in order to reduce the need to do complex computations about size, position and overlap. &lt;/p&gt;

&lt;h1&gt;Information About Arguments in the Property Grid&lt;/h1&gt;

&lt;p&gt;Now, on hover we will display the information about the arguments and properties of the selected item, and additionally, we will pick up the System.ComponentModel.DesscriptionAttribute data as well.&amp;#160; The following code:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;sealed&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MySimpleActivity : CodeActivity&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    [Description(&lt;span class="str"&gt;&amp;quot;This is a basic argument which will be used to compute the end value&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; InArgument&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; Text { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Execute(CodeActivityContext context)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    { ...&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;will show up like this in the property grid:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb.png" width="284" height="225" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;Bonus Feature: Additional Toolbox Organization&lt;/h1&gt;

&lt;p&gt;Rather than go with the “big flat list” approach, we’ve made the organization of items in the toolbox a little more granular.&amp;#160; This also shows some of the updated icons for the activities :-) &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignerEnhancementsinVS2010Beta2_9B17/image_thumb_1.png" width="278" height="464" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I’m really excited that beta2 is out the door, and I can’t wait to start hearing about folks using it.&amp;#160; I’ll start blogging a little more, and there are a few folks on my team that will start talking about some other interesting designer topics. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9910043" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/dalmJedAU0s" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><category term="vs2010" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/10/20/wf4-designer-enhancements-in-vs-2010-beta-2.aspx</feedburner:origLink></entry><entry><title>Introduction to WF Designer Rehosting (Part 2)</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/Dxxg-wG4LGE/introduction-to-wf-designer-rehosting-part-2.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/06/17/introduction-to-wf-designer-rehosting-part-2.aspx</id><published>2009-06-17T20:18:26Z</published><updated>2009-06-17T20:18:26Z</updated><content type="html">&lt;p&gt;&lt;em&gt;standard beta disclaimer.&amp;#160; This is written against the beta1 API’s.&amp;#160; If this is 2014, the bits will look different.&amp;#160; When the bits update, I will make sure to have a new post that updates these (or points to SDK samples that do)&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;In yesterday’s post, we went over the core components of the designer.&amp;#160; Let’s now take that and build that rehosts the designer, and then we’ll circle back around and talk about what we did and what comes next.&lt;/p&gt;  &lt;p&gt;Start VS, Create a new project, and select a WPF project&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb.png" width="553" height="398" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Inside the VS project add references to the System.Activities.* assemblies.&amp;#160; For now, that list looks like&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;System.Activities.dll&lt;/li&gt;    &lt;li&gt;System.Activities.Design.Base.dll&lt;/li&gt;    &lt;li&gt;System.Activities.Design.dll&lt;/li&gt;    &lt;li&gt;System.Activities.Core.Design.dll&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_1.png" width="355" height="292" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You might think the list of design assemblies is excessive.&amp;#160; We’ll be collapsing probably into two design assemblies, one with the designer infrastructure and one with the activity designers in subsequent milestones.&lt;/p&gt;  &lt;p&gt;Create some layout in the WPF window to hold the various designer elements.&amp;#160; I usually do a three column grid for toolbox, property grid and designer canvas.&lt;/p&gt;  &lt;p&gt;The XAML for this looks roughly like this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;BlogPostRehosting.Window1&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Window1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;664&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;831&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;3*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now that we’ve got the layout down, let’s get down to business.&amp;#160; First let’s just get an app that displays the workflow designer and then we will add some other interesting features. We wanted to make it easy to get a canvas onto your host application, and to program against it.&amp;#160; The key type that we use is &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner(VS.100).aspx"&gt;WorkflowDesigner&lt;/a&gt;, this encapsulates all of the functionality, and operating context, required.&amp;#160; Let’s take a quick look at the type definition &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td width="334"&gt;Name&lt;/td&gt;

      &lt;td width="365"&gt;Description&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.context(VS.100).aspx"&gt;Context&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Gets or sets an EditingContext object that is a collection of services shared between all elements contained in the designer and used to interact between the host and the designer. Services are published and requested through the EditingContext.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.contextmenu(VS.100).aspx"&gt;ContextMenu&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Gets the context menu for this designer.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.debugmanagerview(VS.100).aspx"&gt;DebugManagerView&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.debug.debuggerservice(VS.100).aspx"&gt;Provides a DebuggerServicethat is used for runtime debugging. &lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.propertygridfontandcolordata(VS.100).aspx"&gt;PropertyGridFontAndColorData&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Sets the property grid font and color data.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.propertyinspectorview(VS.100).aspx"&gt;PropertyInspectorView&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Returns a UI element that allows the user to view and edit properties of the workflow.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.text(VS.100).aspx"&gt;Text&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Gets or sets the XAML string representation of the workflow.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.view(VS.100).aspx"&gt;View&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Returns a UI element that allows the user to view and edit the workflow visually. &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The editing context is where we will spend more time in the future, for now the View is probably what’s most interesting, as this is the primary designer canvas.&amp;#160; There are also some useful methods to load and persist the workflow as well. &lt;/p&gt;

&lt;p&gt;Let’s start off real simple, and write some code that will display a basic sequence, and we’ll get more sophisticated as we go along.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Design;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Core.Design;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Statements;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; BlogPostRehosting&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="rem"&gt;/// Interaction logic for Window1.xaml&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Window1 : Window&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Window1()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            InitializeComponent();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            LoadWorkflowDesigner();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LoadWorkflowDesigner()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            WorkflowDesigner wd = &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowDesigner();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;            (&lt;span class="kwrd"&gt;new&lt;/span&gt; DesignerMetadata()).Register();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            wd.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                            { &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;                                Activities = &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;                                {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Persist(), &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;                                }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;                            });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            Grid.SetColumn(wd.View, 1);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            grid1.Children.Add(wd.View);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Let’s walk through this line by line:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Line 22, construct the workflow designer&lt;/li&gt;

  &lt;li&gt;Line 23, Call Register on the DesignerMetadata class.&amp;#160; Note that this associates all of the out of the box activities with their out of the box designers.&amp;#160; This is optional as a host may wish to provide custom editors for all or some of the out of box activities, or may not be using the out of box activities.&lt;/li&gt;

  &lt;li&gt;Line 24-31, Call Load, passing in an instance of an object graph to display.&amp;#160; This gives the host some flexibility, as this instance could come from XAML, a database, JSON, user input, etc.&amp;#160; We simply create a basic sequence with two activities&lt;/li&gt;

  &lt;li&gt;Line 32, set the column for the view&lt;/li&gt;

  &lt;li&gt;Line 33, add the view to the display&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives us the following application:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_2.png" width="466" height="389" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now, that was pretty simple, but we’re also missing some key things, namely, the property grid.&amp;#160; It’s important to note however that this has all of the functionality of the designer (the variables designer, the overview map, etc.&amp;#160; This will react just the same as if you were building the workflow in VS.&amp;#160; &lt;/p&gt;

&lt;p&gt;Let’s add the property grid by adding the following two lines:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Grid.SetColumn(wd.PropertyInspectorView, 2);
grid1.Children.Add(wd.PropertyInspectorView);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This will let us see the property grid (so things get a little more interesting).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_3.png" width="381" height="315" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So, we’re able to display the workflow and interact with it, but we probably also want to have a constrained authoring experience (not just editing), so that comes in the form of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.toolboxcontrol(VS.100).aspx"&gt;ToolboxControl&lt;/a&gt;.&amp;#160; For the sake of this blog post, we’ll use this in XAML, but we certainly can code against it imperatively as well.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;BlogPostRehosting.Window1&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:sad&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System.Activities.Design;assembly=System.Activities.Design&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:sys&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System;assembly=mscorlib&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Window1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;664&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;831&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sys:String&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;AssemblyName&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sys:String&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;grid1&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;3*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl.Categories&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxCategoryItemsCollection&lt;/span&gt; &lt;span class="attr"&gt;CategoryName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Basic&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.Sequence&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.If&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.Parallel&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.WriteLine&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.Persist&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxCategoryItemsCollection&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl.Categories&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;This lets me specify the items I want to allow a user to drop.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_4.png" width="627" height="522" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The thing that is interesting to point out here is that we’ve built a full featured, constrained editor (with things like copy paste, undo/redo, etc) with not too much code.&lt;/p&gt;

&lt;p&gt;Next time, we’ll get into to doing some more interesting bits as well to interact with the item being edited, serialize to XAML, and explore the editing context some more.&amp;#160; Let me know what you think!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9769899" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/Dxxg-wG4LGE" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="vs10" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs10/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/06/17/introduction-to-wf-designer-rehosting-part-2.aspx</feedburner:origLink></entry><entry><title>Introduction to WF Designer Rehosting (Part 1)</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/3DpHUAvkrh0/introduction-to-wf-designer-rehosting-part-1.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/06/17/introduction-to-wf-designer-rehosting-part-1.aspx</id><published>2009-06-17T03:31:19Z</published><updated>2009-06-17T03:31:19Z</updated><content type="html">&lt;p&gt;&lt;em&gt;standard beta disclaimer.&amp;#160; This is written against the beta1 API’s.&amp;#160; If this is 2014, the bits will look different.&amp;#160; When the bits update, I will make sure to have a new post that updates these (or points to SDK samples that do)&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In WF3, we allowed our customers to rehost the WF designer inside their own applications.&amp;#160; This has many &lt;a href="http://msdn.microsoft.com/en-us/library/cc835242.aspx"&gt;reasons&lt;/a&gt;, usually about monitoring a workflow or allowing an end user to customize a constrained workflow (visual construction of an approval process, for instance). This &lt;a href="http://msdn.microsoft.com/en-us/library/aa480213.aspx"&gt;article&lt;/a&gt; became the gold standard for writing rehosted applications.&amp;#160; As we were planning our work for the WF4 designer, this was certainly a scenario we considered, and one we wanted to make easier.&amp;#160; &lt;/p&gt;  &lt;p&gt;This post consists of a few parts&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Designer architecture – introduce the pieces, parts and terms we’ll use throughout &lt;/li&gt;    &lt;li&gt;Simple rehosting – getting it up and running &lt;/li&gt;    &lt;li&gt;What to do next &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;Designer Architecture&lt;/h1&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehosting_ECB0/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehosting_ECB0/image_thumb.png" width="639" height="284" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There are a few key components here&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Source      &lt;ul&gt;       &lt;li&gt;In VS, this is xaml, but this represents the durable storage of the “thing” we are editing &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Instance      &lt;ul&gt;       &lt;li&gt;This is the in memory representation of the item being edited.&amp;#160; In vs2010 for the WF designer, this is a hierarchy of System.Activities instances (an object tree) &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Model Item Tree      &lt;ul&gt;       &lt;li&gt;This serves as an intermediary between the view and the instance, and is responsible for change notification and tracking things like undo state &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Design View      &lt;ul&gt;       &lt;li&gt;This is the visual editing view that is surfaced to the user, the designers are written using WPF, which uses plain old data binding in order to wire up to the underlying model items (which represent the data being edited). &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Metadata Store      &lt;ul&gt;       &lt;li&gt;This is a mapping between type and designers, an attribute table for lack of a better term.&amp;#160; This is how we know what designer to use for what type &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I’ll go into more detail about these pieces and parts in future posts as well, but this is the mental model of the things I will be talking about as we go through the designer. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Stay tuned, part 2 will come tomorrow!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9763452" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/3DpHUAvkrh0" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="vs10" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs10/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="rehosting" scheme="http://blogs.msdn.com/mwinkle/archive/tags/rehosting/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/06/17/introduction-to-wf-designer-rehosting-part-1.aspx</feedburner:origLink></entry><entry><title>Types, Metatypes and Bears, Oh my!</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/Z4hQVnO4RyQ/types-metatypes-and-bears-oh-my.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/06/10/types-metatypes-and-bears-oh-my.aspx</id><published>2009-06-09T23:23:00Z</published><updated>2009-06-09T23:23:00Z</updated><content type="html">&lt;H2&gt;&lt;STRONG&gt;***** UPDATE: Please see &lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/10/23/types-metatypes-and-bears-redux.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/10/23/types-metatypes-and-bears-redux.aspx"&gt;this post&lt;/A&gt; for how these features and functionality work in Beta2 *****&lt;/STRONG&gt;&lt;/H2&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="Polar Bear" href="http://www.flickr.com/photos/21208051@N00/108149173/" mce_href="http://www.flickr.com/photos/21208051@N00/108149173/"&gt;&lt;IMG border=0 alt="Polar Bear" src="http://static.flickr.com/52/108149173_990037d136.jpg" mce_src="http://static.flickr.com/52/108149173_990037d136.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;image courtesy of flickr user &lt;A href="http://www.flickr.com/photos/chodhound/108149173/in/set-72057594075424977/" mce_href="http://www.flickr.com/photos/chodhound/108149173/in/set-72057594075424977/"&gt;chodhound&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;This post comes about after a little conversation on the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/b07e86c6-c000-4e77-bb56-9600ecf03144" mce_href="http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/b07e86c6-c000-4e77-bb56-9600ecf03144"&gt;forums&lt;/A&gt; where I was talking about using the xaml stack save and load objects. &lt;/P&gt;
&lt;P&gt;Here’s what I said:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Bob&amp;nbsp; (it's a little late in Seattle, so I don't have a code editor handy, so there may be some minor errors below), &lt;BR&gt;If you want to serialize any object graph to xaml, simply look at the XamlServices.Save() api that's in System.Xaml.&amp;nbsp; I'm sure there are a few SDK samples around that as well.&amp;nbsp; It takes in a file name to output to, a text writer or a stream, so you get to pick your poison for destination.&amp;nbsp; Similarly, if you want to get an object graph deserialized from Xaml, you can just use XamlServices.Load() again, with overloads for files, streams, text, xml, and xaml readers. &lt;BR&gt;To see this API, just do something like&lt;/P&gt;&lt;PRE&gt;Sequence s = new Sequence { Activities = { new Persist(), new Persist() } };
XamlServices.Save(fileNameVar, s);&lt;/PRE&gt;
&lt;P&gt;If you want to read, basically do the reverse. &lt;BR&gt;Save and Load are convinient helper functions to operate on the whole of the doc, there Xaml stack surfaces much more programmability and has a nice node stream style API that lets you plug in while nodes are being read and written. &lt;BR&gt;Now, if you want to deserialize a Xaml file that contains an x:Class directive, you are going to need to do a bit more work (and it depends what you want to serialize to or from).&amp;nbsp; I'll try to blog about that in the next week or so.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now, I want to take a little bit of time to explain the last part.&lt;/P&gt;
&lt;P&gt;A convenient way to think about XAML is a way to write down objects, really, instances of objects.&amp;nbsp; That said I am not limited to writing down just instances, I can actually write down type definitions as well.&amp;nbsp; I do this using the x:Class attribute.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Consider the following XAML snippet&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;Activity x:Class="foo" ...&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;This is roughly equivalent to the following C#&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; foo : Activity
{
...&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;Now, “normally” what happens with XAML like this in .xaml files is that it is used in a VS project and it is set up so that there is a build task who has the job of generating a type from that XAML so that you can use that type subsequently in your application.&amp;nbsp; This works basically the same way for WPF as well as WF. &lt;/P&gt;
&lt;P&gt;However, if you think about trying simply deserialize this, it’s a little confusing what this will actually deserialize to.&amp;nbsp; This is a type definition, so if you simply try to pass it to XamlServices.Load(), you will encounter an exception:&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;Error System.Xaml.XamlObjectWriterException: No matching constructor found on type System.Activities.Activity. You can use the Arguments or FactoryMethod direct ives to construct this type. ---&amp;gt; System.MissingMethodException: No default constructor found for type System.Activities.Activity. You can use the Arguments or FactoryMethod directives to construct this type. &lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xaml.Runtime.ClrObjectRuntime.DefaultCtorXamlActivator.EnsureConstructorDelegate(XamlType xamlType) &lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xaml.Runtime.ClrObjectRuntime.DefaultCtorXamlActivator.CreateInstance(XamlType xamlType) &lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args) &lt;BR&gt;&amp;nbsp;&amp;nbsp; at System.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args) &lt;BR&gt;&amp;nbsp;&amp;nbsp; --- End of inner exception stack trace ---&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;So, if we want to deserialize that, we need to ask the question first: “Why do we want to deserialize it?”&lt;/P&gt;
&lt;H2&gt;Deserialize to Execute&lt;/H2&gt;
&lt;P&gt;If we want to simply use the activity we’ve created and have it execute, we have a special type, &lt;A href="http://msdn.microsoft.com/en-us/library/system.activities.dynamicactivity(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.activities.dynamicactivity(VS.100).aspx"&gt;DynamicActivity&lt;/A&gt;.&amp;nbsp; DynamicActivity lets you execute the activity, and rather than creating a type for it, will allow you to pass in the arguments in the typical Dictionary&amp;lt;string,object&amp;gt; way that we are used to.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Imagine a xaml file, just sitting on disk somewhere that looks like this (a workflow that concats two strings):&amp;nbsp; &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Activity&lt;/SPAN&gt; &lt;SPAN class=attr&gt;mc:Ignorable&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;=""&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;x:Class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="WorkflowConsoleApplication1.Sequence1"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/netfx/2009/xaml/activities/design"&lt;/SPAN&gt;
     &lt;SPAN class=attr&gt;xmlns:__Sequence1&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clr-namespace:WorkflowConsoleApplication1;"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:mc&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:p&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/netfx/2009/xaml/activities"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Members&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Property&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="argument1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="p:InArgument(x:String)"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Property&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="argument2"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="p:InArgument(x:String)"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Members&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Sequence&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:WriteLine&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;[argument1 + " " + argument2]&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:WriteLine&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Sequence&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Activity&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;The code for this is the following:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; o = WorkflowXamlServices.Load(File.OpenRead(&lt;SPAN class=str&gt;"Sequence1.xaml"&lt;/SPAN&gt;));
Console.WriteLine(&lt;SPAN class=str&gt;"Success {0}"&lt;/SPAN&gt;, o.GetType());
DynamicActivity da = o &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; DynamicActivity;da.Properties.ToList().ForEach(ap =&amp;gt; Console.WriteLine(&lt;SPAN class=str&gt;"argument: {0}"&lt;/SPAN&gt;, ap.Name));
WorkflowInvoker.Invoke(da, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Dictionary&amp;lt;&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt;&amp;gt; { { &lt;SPAN class=str&gt;"argument1"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"foo"&lt;/SPAN&gt; }, { &lt;SPAN class=str&gt;"argument2"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"bar"&lt;/SPAN&gt; } });&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;H2&gt;Deserialize to “Design”&lt;/H2&gt;
&lt;P&gt;At design time, we have an even more interesting problem.&amp;nbsp; Our designer is an instance editor, and, as such, it must always edit an instance of “something”.&amp;nbsp; In our case, we actually do some work in our design time xaml reader and writer to deserialize into a metatype, an instance of a type whose sole purpose in life is to describe the activity.&amp;nbsp; In Beta1, this is called &lt;A href="http://msdn.microsoft.com/en-us/library/system.activities.design.xaml.activityschematype(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.activities.design.xaml.activityschematype(VS.100).aspx"&gt;ActivitySchemaType&lt;/A&gt;.&amp;nbsp; ActivitySchemaType simply models the type structure of an activity, complete with properties, etc&amp;nbsp; If you want to construct an instance of an ActivitySchemaType in code, you can, and then you could use the &lt;A href="http://msdn.microsoft.com/en-us/library/system.activities.design.xaml.designtimexamlwriter(VS.100).aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.activities.design.xaml.designtimexamlwriter(VS.100).aspx"&gt;DesignTimeXamlWriter&lt;/A&gt; in order to properly serialize out to an Activity x:class xaml file.&amp;nbsp; The following code works on an ActivitySchemaType in memory and then serializes it:&lt;/P&gt;&lt;PRE class=csharpcode&gt;XamlSchemaContext xsc = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; XamlSchemaContext();
ActivitySchemaType ast = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ActivitySchemaType()
{
    Name = &lt;SPAN class=str&gt;"foo"&lt;/SPAN&gt;,
    Members = 
     {
        &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Property { Name=&lt;SPAN class=str&gt;"argument1"&lt;/SPAN&gt;, Type = xsc.GetXamlType(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(InArgument&amp;lt;&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;&amp;gt;)) }

     },
    Body = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Sequence { Activities = { &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Persist(), &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Persist() } }
};
StringBuilder sb = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; StringBuilder();

DesignTimeXamlWriter dtxw = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; DesignTimeXamlWriter(
    &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; StringWriter(sb),
    xsc, &lt;SPAN class=str&gt;"foo"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"bar.rock"&lt;/SPAN&gt;);

XamlServices.Save(dtxw, ast);
Console.WriteLine(&lt;SPAN class=str&gt;"you wrote:"&lt;/SPAN&gt;);
ConsoleColor old = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine(sb.ToString());
Console.ForegroundColor = old;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;This is what the output looks like:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Activity&lt;/SPAN&gt; &lt;SPAN class=attr&gt;mc:Ignorable&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;=""&lt;/SPAN&gt;
     &lt;SPAN class=attr&gt;x:Class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="foo"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/netfx/2009/xaml/activities/design"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:__foo&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clr-namespace:bar.rock;"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:mc&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:p&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/netfx/2009/xaml/activities"&lt;/SPAN&gt; 
     &lt;SPAN class=attr&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Members&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Property&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="argument1"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="p:InArgument(x:String)"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;x:Members&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Sequence&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Persist&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Persist&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Sequence&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;p:Activity&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;If you want to read in from this, you have to do a little bit of trickery with the designer as DesignTimeXamlReader is not a public type in beta1.&amp;nbsp; &lt;/P&gt;&lt;PRE class=csharpcode&gt;WorkflowDesigner wd = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WorkflowDesigner();
wd.Load(&lt;SPAN class=str&gt;"Sequence1.xaml"&lt;/SPAN&gt;);
&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; obj = wd.Context.Services.GetService&amp;lt;ModelService&amp;gt;().Root.GetCurrentValue();
Console.WriteLine(&lt;SPAN class=str&gt;"object read type: {0}"&lt;/SPAN&gt;, obj.GetType());
ActivitySchemaType schemaType = obj &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; ActivitySchemaType;
Console.WriteLine(&lt;SPAN class=str&gt;"schema type name: {0}"&lt;/SPAN&gt;, schemaType.Name);
schemaType.Members.ToList().ForEach(p =&amp;gt; Console.WriteLine(&lt;SPAN class=str&gt;"argument: {0}, type: {1}"&lt;/SPAN&gt;, p.Name, p.Type));&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;That wraps up our tour of the ways to read (and write)&amp;nbsp; &amp;lt;Activity x:Class xaml&lt;/P&gt;
&lt;P&gt;Here’s the full text of the little program I put together to execute this, also make sure to drop a sequence1.xaml into your execution directory if you want this to not throw :-) &lt;/P&gt;
&lt;HR&gt;

&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Collections.Generic;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Linq;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Text;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Xaml;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Activities.Statements;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Activities;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.IO;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Activities.Design.Xaml;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Windows.Markup;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Xml;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Activities.Design;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Activities.Design.Services;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; ConsoleApplication2&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; Program&lt;/PRE&gt;&lt;PRE&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;        [STAThread()]&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Main(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] args)&lt;/PRE&gt;&lt;PRE class=alt&gt;        {&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;bool&lt;/SPAN&gt; doStuff = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;            Guid g = Guid.NewGuid();&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;while&lt;/SPAN&gt; (doStuff)&lt;/PRE&gt;&lt;PRE class=alt&gt;            {&lt;/PRE&gt;&lt;PRE&gt;                Console.WriteLine();&lt;/PRE&gt;&lt;PRE class=alt&gt;                Console.WriteLine(&lt;SPAN class=str&gt;"What do you want to do?"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                Console.WriteLine(&lt;SPAN class=str&gt;"    read [x]:class xaml with XamlServices"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                Console.WriteLine(&lt;SPAN class=str&gt;"    read x:class xaml with W[o]rkflowXamlServices"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                Console.WriteLine(&lt;SPAN class=str&gt;"    [w]rite an ActivitySchemaType"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                Console.WriteLine(&lt;SPAN class=str&gt;"    r[e]ad an ActivitySchemaType"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                Console.WriteLine(&lt;SPAN class=str&gt;"    [q]uit"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                Console.WriteLine();&lt;/PRE&gt;&lt;PRE&gt;                &lt;SPAN class=kwrd&gt;char&lt;/SPAN&gt; c = Console.ReadKey(&lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;).KeyChar;&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=kwrd&gt;switch&lt;/SPAN&gt; (c)&lt;/PRE&gt;&lt;PRE&gt;                {&lt;/PRE&gt;&lt;PRE class=alt&gt;                    &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; &lt;SPAN class=str&gt;'w'&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE&gt;                        XamlSchemaContext xsc = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; XamlSchemaContext();&lt;/PRE&gt;&lt;PRE class=alt&gt;                        ActivitySchemaType ast = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; ActivitySchemaType()&lt;/PRE&gt;&lt;PRE&gt;                        {&lt;/PRE&gt;&lt;PRE class=alt&gt;                            Name = &lt;SPAN class=str&gt;"foo"&lt;/SPAN&gt;,&lt;/PRE&gt;&lt;PRE&gt;                            Members = &lt;/PRE&gt;&lt;PRE class=alt&gt;                             {&lt;/PRE&gt;&lt;PRE&gt;                                &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Property { Name=&lt;SPAN class=str&gt;"argument1"&lt;/SPAN&gt;, Type = xsc.GetXamlType(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(InArgument&amp;lt;&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;&amp;gt;)) }&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;                             },&lt;/PRE&gt;&lt;PRE class=alt&gt;                            Body = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Sequence { Activities = { &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Persist(), &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Persist() } }&lt;/PRE&gt;&lt;PRE&gt;                        };&lt;/PRE&gt;&lt;PRE class=alt&gt;                        StringBuilder sb = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; StringBuilder();&lt;/PRE&gt;&lt;PRE&gt;                        &lt;/PRE&gt;&lt;PRE class=alt&gt;                        DesignTimeXamlWriter dtxw = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; DesignTimeXamlWriter(&lt;/PRE&gt;&lt;PRE&gt;                            &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; StringWriter(sb),&lt;/PRE&gt;&lt;PRE class=alt&gt;                            xsc, &lt;SPAN class=str&gt;"foo"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"bar.rock"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE&gt;                        &lt;/PRE&gt;&lt;PRE class=alt&gt;                        XamlServices.Save(dtxw, ast);&lt;/PRE&gt;&lt;PRE&gt;                        Console.WriteLine(&lt;SPAN class=str&gt;"you wrote:"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                        ConsoleColor old = Console.ForegroundColor;&lt;/PRE&gt;&lt;PRE&gt;                        Console.ForegroundColor = ConsoleColor.DarkGray;&lt;/PRE&gt;&lt;PRE class=alt&gt;                        Console.WriteLine(sb.ToString());&lt;/PRE&gt;&lt;PRE&gt;                        Console.ForegroundColor = old;&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;                    &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; &lt;SPAN class=str&gt;'x'&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE&gt;                        &lt;SPAN class=kwrd&gt;try&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;                        {&lt;/PRE&gt;&lt;PRE&gt;                            &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; o = XamlServices.Load(File.OpenRead(&lt;SPAN class=str&gt;"Sequence1.xaml"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;PRE class=alt&gt;                            Console.WriteLine(&lt;SPAN class=str&gt;"Success{0}"&lt;/SPAN&gt;, o.GetType());&lt;/PRE&gt;&lt;PRE&gt;                        }&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;catch&lt;/SPAN&gt; (Exception ex)&lt;/PRE&gt;&lt;PRE&gt;                        {&lt;/PRE&gt;&lt;PRE class=alt&gt;                            Console.WriteLine(&lt;SPAN class=str&gt;"Error {0}"&lt;/SPAN&gt;, ex);&lt;/PRE&gt;&lt;PRE&gt;                        }&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;                    &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; &lt;SPAN class=str&gt;'o'&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;try&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;                        {&lt;/PRE&gt;&lt;PRE class=alt&gt;                            &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; o = WorkflowXamlServices.Load(File.OpenRead(&lt;SPAN class=str&gt;"Sequence1.xaml"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;PRE&gt;                            Console.WriteLine(&lt;SPAN class=str&gt;"Success {0}"&lt;/SPAN&gt;, o.GetType());&lt;/PRE&gt;&lt;PRE class=alt&gt;                            DynamicActivity da = o &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; DynamicActivity;&lt;/PRE&gt;&lt;PRE&gt;                            da.Properties.ToList().ForEach(ap =&amp;gt; Console.WriteLine(&lt;SPAN class=str&gt;"argument: {0}"&lt;/SPAN&gt;, ap.Name));&lt;/PRE&gt;&lt;PRE class=alt&gt;                            WorkflowInvoker.Invoke(da, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Dictionary&amp;lt;&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt;&amp;gt; { { &lt;SPAN class=str&gt;"argument1"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"foo"&lt;/SPAN&gt; }, { &lt;SPAN class=str&gt;"argument2"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"bar"&lt;/SPAN&gt; } });&lt;/PRE&gt;&lt;PRE&gt;                        }&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;catch&lt;/SPAN&gt; (Exception ex)&lt;/PRE&gt;&lt;PRE&gt;                        {&lt;/PRE&gt;&lt;PRE class=alt&gt;                            Console.WriteLine(&lt;SPAN class=str&gt;"Error {0}"&lt;/SPAN&gt;, ex);&lt;/PRE&gt;&lt;PRE&gt;                        }&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;                    &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; &lt;SPAN class=str&gt;'e'&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE class=alt&gt;                        WorkflowDesigner wd = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; WorkflowDesigner();&lt;/PRE&gt;&lt;PRE&gt;                        wd.Load(&lt;SPAN class=str&gt;"Sequence1.xaml"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; obj = wd.Context.Services.GetService&amp;lt;ModelService&amp;gt;().Root.GetCurrentValue();&lt;/PRE&gt;&lt;PRE&gt;                        Console.WriteLine(&lt;SPAN class=str&gt;"object read type: {0}"&lt;/SPAN&gt;, obj.GetType());&lt;/PRE&gt;&lt;PRE class=alt&gt;                        ActivitySchemaType schemaType = obj &lt;SPAN class=kwrd&gt;as&lt;/SPAN&gt; ActivitySchemaType;&lt;/PRE&gt;&lt;PRE&gt;                        Console.WriteLine(&lt;SPAN class=str&gt;"schema type name: {0}"&lt;/SPAN&gt;, schemaType.Name);&lt;/PRE&gt;&lt;PRE class=alt&gt;                        schemaType.Members.ToList().ForEach(p =&amp;gt; Console.WriteLine(&lt;SPAN class=str&gt;"argument: {0}, type: {1}"&lt;/SPAN&gt;, p.Name, p.Type));&lt;/PRE&gt;&lt;PRE&gt;                        &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;                    &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; &lt;SPAN class=str&gt;'q'&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE&gt;                        doStuff = &lt;SPAN class=kwrd&gt;false&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;                        &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;                    &lt;SPAN class=kwrd&gt;default&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;PRE&gt;                        &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE class=alt&gt;                }&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;            }&lt;/PRE&gt;&lt;PRE&gt;            Console.WriteLine(&lt;SPAN class=str&gt;"All done"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE class=alt&gt;            Console.ReadLine();&lt;/PRE&gt;&lt;PRE&gt;        }&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; CreateWfObject()&lt;/PRE&gt;&lt;PRE class=alt&gt;        {&lt;/PRE&gt;&lt;PRE&gt;            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Sequence { Activities = { &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Persist(), &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Persist() } };&lt;/PRE&gt;&lt;PRE class=alt&gt;        }&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9718703" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/Z4hQVnO4RyQ" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="vs10" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs10/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="xaml" scheme="http://blogs.msdn.com/mwinkle/archive/tags/xaml/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/06/10/types-metatypes-and-bears-oh-my.aspx</feedburner:origLink></entry><entry><title>Introducing the WF4 Designer</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/CobffhheRhg/introducing-the-wf4-designer.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/05/20/introducing-the-wf4-designer.aspx</id><published>2009-05-20T23:27:51Z</published><updated>2009-05-20T23:27:51Z</updated><content type="html">&lt;p&gt;&lt;em&gt;// standard disclaimer applies, this is based on the released Beta 1 bits, things are subject to change, if you are reading this in 2012, things may be, look, smell, work differently.&amp;#160; That said, if it’s 2012 and you’re reading this, drop me a line and let me know how you found this!&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As you might have heard, &lt;a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx"&gt;Beta1 of VS is out the door, and available to the public sometime today&lt;/a&gt;.&amp;#160; As you may know we’ve done a bunch of work for WF4, and I wanted to give a quick, high level overview of the designer.&amp;#160; &lt;a href="http://blogs.msdn.com/endpoint/archive/2009/05/20/vs-2010-and-net-framework-4-0-beta1-available-for-download.aspx"&gt;Here’s a good overview&lt;/a&gt; for the new WF bits all up.&lt;/p&gt;  &lt;p&gt;First, let’s start with your existing WF projects.&amp;#160; What happens if I want to create a 3.5 workflow?&amp;#160; We’re still shipping that designer, in fact, let’s start there on our tour.&amp;#160; This shows of a feature of VS that’s&amp;#160; pretty cool, multitargeting.&amp;#160; &lt;/p&gt;  &lt;p&gt;Click New Project&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb.png" width="596" height="429" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice the “Framework Version” dropdown in the upper right hand corner. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_28.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_13.png" width="409" height="186" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This tells VS which version of the framework you would like the project you are creating to target.&amp;#160; This means you can still work on your existing projects in VS 2010 without upgrading your app to the new framework.&amp;#160; Let’s pick something that’s not 4.0, namely 3.5.&amp;#160; You’ll note that the templates may have updated a bit, select Workflow from the left hand tree view and see what shows up.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_1.png" width="604" height="446" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There isn’t anything magical about what happens next, you will now see the 3.5 designer inside of VS2010.&amp;#160; You’re able to build, create, edit and update your existing WF applications.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_2.png" width="424" height="523" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Let’s move on and switch over to a 4.0 workflow.&lt;/p&gt;  &lt;p&gt;Create a new project and select 4.0&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_3.png" width="529" height="389" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Create a new WF Sequential Console application and name it “SampleProject”.&amp;#160; Click Ok.&lt;/p&gt;  &lt;p&gt;We’ll do a little bit of work here, but you will shortly see the WF 4.0 designer.&amp;#160; It looks a little different from the 3.x days, we’ve taken this time to update the designer pretty substantially.&amp;#160; We’ve built it on top of WPF, which opens up the doors for us to do a lot of interesting things.&amp;#160; If you were at PDC and saw any Quadrant demos, you might think that these look similar. We haven’t locked on the final look and feel yet, so expect to see some additional changes there, but submit your feedback early and often, we want to know what you think.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_10.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_4.png" width="464" height="575" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Let’s drop some activities into our sequence and see what’s there to be seen.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_12.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" align="right" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_5.png" width="143" height="561" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We’ve categorized the toolbox into functional groupings for the key activities.&amp;#160; We heard a lot of feedback that it was tough to know what to use when, so we wanted to provide a little more help with some richer default categories.&amp;#160; Add an Assign activity, a WriteLine activity and a Delay activity to the canvas by clicking and dragging over the to the sequence designer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_14.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_6.png" width="223" height="305" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You’ll note that we’ve now got some icons on each activity indicating something is not correct.&amp;#160; This is a result of the validation executing and returning details about what is wrong.&amp;#160; Think of these as the little red squiggles that show up when you spell something wrong.&amp;#160; You can hover over the icon to see what’s wrong&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_16.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_7.png" width="467" height="110" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can also see that errors will bubble up to their container, so hovering over sequence will tell you that there is a problem with the child activities.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_18.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_8.png" width="445" height="290" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;What if I have a big workflow, and what if I want to see a more detailed listing of errors?&amp;#160; Open up the Error View and you will see the validation results are also displayed here.&amp;#160; You’ll note there is some minor formatting weirdness.&amp;#160; This is a bug that we fixed but not in time for the Beta1 release.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_20.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_9.png" width="650" height="178" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now, let’s actually wire up some data to this workflow.&amp;#160; WF4 has done a lot of work to be much more crisp about the way we think about data within the execution environment of a workflow. We divide the world into two types of data, Arguments, and Variables.&amp;#160; If you mentally map these to the way you write a method in code (parameters, and state internal to the method), you are one the right track.&amp;#160; Arguments determine the shape of an activity, what goes in, what goes out.&amp;#160; Variables allocate storage within the context of an activities execution.&amp;#160; The neat thing about variables, once the containing activity is done, we can get rid of the variables, as our workflow no longer needs them (note, we pass the important data in and out through the arguments).&amp;#160; To do this, we have two special designers on the canvas that contain information about the arguments and variables in your workflow &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_42.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_20.png" width="631" height="245" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;First, let’s click on the Argument designer and pass in some data.&amp;#160; &lt;/p&gt;  &lt;p&gt;Arguments consist of a few important elements&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Name &lt;/li&gt;    &lt;li&gt;Type &lt;/li&gt;    &lt;li&gt;Direction &lt;/li&gt;    &lt;li&gt;Default Value (Optional) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_22.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_10.png" width="436" height="298" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Most of these are self explanatory, with the one exception being the Direction.&amp;#160; You’ll note that this has In, Out and Property.&amp;#160; Now, when you are editing the arguments, you are actually editing the properties of the underlying type you are creating (I’ll explain more about this in a future post).&amp;#160; A more appropriate name might be “Property Editor” but the vast majority of what you’ll be creating with it is arguments.&amp;#160; Anyway, If you select In or Out, this basically wraps the type T in an InArgument, so it becomes a property of type InArgument&amp;lt;T&amp;gt;.&amp;#160; We just provide a bit of a shorthand so you don’t always have to pick InArgument as the type.&amp;#160; The default value takes an expression, but in this case, we won’t be using it.&lt;/p&gt;  &lt;p&gt;Let’s go ahead and add an argument of type TimeSpan named DelayTime.&amp;#160; You’ll need to select browse for types and then search for the TimeSpan&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_24.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_11.png" width="484" height="557" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Variables are similar, but slightly different, variables have a few important elements:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Name &lt;/li&gt;    &lt;li&gt;Type &lt;/li&gt;    &lt;li&gt;Scope &lt;/li&gt;    &lt;li&gt;Default Value (Optional) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Remember earlier, I mentioned that variable is part of an activity, this is what Scope refers to.&amp;#160; Variables will only show up to be the scope of the selected activity, so if you don’t see any, make sure to select the Sequence, and then you will be able to add a variable.&amp;#160; Let’s add new variable, named StringToPrint, of type String.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_26.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_12.png" width="431" height="297" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now let’s do something with these in the workflow.&amp;#160; One thing I’m particularly happy with that we’ve done on the designer side of things is to enable people to build activity designers more easily.&amp;#160; There are lots of times where you have activities that have just a few key properties that need to be set, and you’d like to be able to see that “at a glance”&amp;#160; The assign designer is like that.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_30.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_14.png" width="267" height="102" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now, let’s dig into expressions.&amp;#160; One big piece of feedback from 3.0 was that people really wanted richer binding experiences.&amp;#160; You see this as well with the WPF data binding .&amp;#160; We’ve taken it to the next level, and allow any expression to be expressed as a set of activities.&amp;#160; What this means is that we do have to “compile” textual expressions into a tree of activities, and this is one of the reasons we use VB to build expressions.&amp;#160; In the fullness of time, other languages will come on board. But how to use it, let’s see.&amp;#160; Click on the “To” text box on the Assign activity.&amp;#160; You will see a brief change of the text box, and then you will be in a VB Expression Editor, or what we’ve come to refer to as “The Expression Text Box” or ETB.&amp;#160; Start typing S, and already you will see intellisense begin to scope down the choices.&amp;#160; This will pick up all of the variables and arguments in scope.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_32.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_15.png" width="330" height="314" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;On the right side, we won’t use any of the passed in arguments, we’ll show off a richer expression.&amp;#160;&amp;#160; Now, the space on the right side of the designer is kind of tight for something lengthy, so go to the property grid and click on the “…” button for the Value property &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_34.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_16.png" width="580" height="404" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;String&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;Someone wants to wait {0} seconds&amp;quot;&lt;/span&gt;, TimeToWait.TotalSeconds)&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This just touches the surface of what is possible with expressions in WF4, we can really get&amp;#160; much richer expressions (3.x expressions are similar to WPF data binding, they are really an “object” + “target” structure).&lt;/p&gt;

&lt;p&gt;Not everything makes it to the canvas of the designer surface, and for that, we have the property grid.&amp;#160; If you’ve used the WPF designer in VS2008, this should look pretty familiar to you.&amp;#160; Select the delay activity, and use the property grid to set the duration property to the InArgument you created above.&amp;#160; This experience is similar, with the ETB embedded into the property grid for arguments. &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Finally, repeat with the WriteLine and bind to the StringToPrint variable.&lt;/p&gt;

&lt;h1&gt;Navigating the Workflow&lt;/h1&gt;

&lt;p&gt;There are two different things that we have to help navigating the workflow, our breadcrumb bar at the top and the overview map (which appears as the “Mini Map” in the beta).&amp;#160; Let’s look at the overview map.&amp;#160; This gives you a view of the entire workflow and the ability to quickly scrub and scroll across it.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_36.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_17.png" width="337" height="531" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Finally, across the top we display our breadcrumbs which are useful when you have a highly nested workflow.&amp;#160; Double click on one of the activities, and you should see the designer “drill into” that activity.&amp;#160; Now notice the breadcrumb bar, it displays where you have been, and by clicking you can navigate back up the hierarchy.&amp;#160; In beta1, we have a pretty aggressive breadcrumb behavior, and so you see “collapsed in place” as the default for many of our designers.&amp;#160; We’re probably going to relax that a bit in upcoming milestones to reduce clicking and provide a better overview of the workflow.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_40.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_19.png" width="402" height="530" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Finally, there may be times where we don’t want to have a designer view, but would rather see the XAML.&amp;#160; To get there, just right click on the file and ask to “View Code”&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_38.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_18.png" width="236" height="362" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This will currently ask you if you are sure that you want to close the designer, and you will then see the XAML displayed in the XML editor.&amp;#160; For the workflow we just created, this is what it looks like:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Activity&lt;/span&gt; &lt;span class="attr"&gt;mc:Ignorable&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;     &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;WorkflowConsoleApplication1.Sequence1&amp;quot;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/netfx/2009/xaml/activities/design&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns:__Sequence1&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:WorkflowConsoleApplication1;&amp;quot;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns:mc&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns:p&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/netfx/2009/xaml/activities&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns:s&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System;assembly=mscorlib&amp;quot;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns:sad&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System.Activities.Debugger;assembly=System.Activities&amp;quot;&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;     &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;x:Members&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;x:Property&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;TimeToWait&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;p:InArgument(s:TimeSpan)&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;x:Members&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;__Sequence1:Sequence1.TimeToWait&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:InArgument&lt;/span&gt; &lt;span class="attr"&gt;x:TypeArguments&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;s:TimeSpan&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;[TimeSpan.FromSeconds(10)]&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:InArgument&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;__Sequence1:Sequence1.TimeToWait&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Sequence&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Sequence.Variables&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Variable&lt;/span&gt; &lt;span class="attr"&gt;x:TypeArguments&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;x:String&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;StringToPrint&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Sequence.Variables&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Assign&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Assign.To&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:OutArgument&lt;/span&gt; &lt;span class="attr"&gt;x:TypeArguments&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;x:String&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;            [StringToPrint]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:OutArgument&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Assign.To&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Assign.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:InArgument&lt;/span&gt; &lt;span class="attr"&gt;x:TypeArguments&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;x:String&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;                  [String.Format(&amp;quot;Someone wants to wait {0} seconds&amp;quot;, TimeToWait.TotalSeconds)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;         &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:InArgument&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Assign.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Assign&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:Delay&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;[TimeToWait]&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Delay&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;p:WriteLine&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;[StringToPrint]&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:WriteLine&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Sequence&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;p:Activity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h1&gt;Executing the Workflow&lt;/h1&gt;

&lt;p&gt;Inside the project you will see the Program.cs to execute the workflow, let’s take a look at that. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; WorkflowConsoleApplication1&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Threading;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Statements;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;            AutoResetEvent syncEvent = &lt;span class="kwrd"&gt;new&lt;/span&gt; AutoResetEvent(&lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            WorkflowInstance myInstance =&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowInstance(&lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence1(),&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;                    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;                        {&lt;span class="str"&gt;&amp;quot;TimeToWait&amp;quot;&lt;/span&gt;, TimeSpan.FromSeconds(3.5) }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;                    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                    );&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            myInstance.OnCompleted = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(WorkflowCompletedEventArgs e) { syncEvent.Set(); };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;            myInstance.OnUnhandledException = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(WorkflowUnhandledExceptionEventArgs e)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;                Console.WriteLine(e.UnhandledException.ToString());&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt; UnhandledExceptionAction.Terminate;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;            };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            myInstance.OnAborted = &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(WorkflowAbortedEventArgs e)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;                Console.WriteLine(e.Reason);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;                syncEvent.Set();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;            };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;            myInstance.Run();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;            syncEvent.WaitOne();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press &amp;lt;Enter&amp;gt; to exit&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;            Console.ReadLine();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;This is the standard program.cs template with two modifications.&amp;#160; The first is passing data into the workflow, indicated by the dictionary we create to pass into the WorkflowInstance.&amp;#160; This should look familiar if you have used WF in the past. &lt;/p&gt;

&lt;pre class="csharpcode"&gt; WorkflowInstance myInstance =
                &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowInstance(&lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence1(),
                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;
                    {
                        {&lt;span class="str"&gt;&amp;quot;TimeToWait&amp;quot;&lt;/span&gt;, TimeSpan.FromSeconds(3.5) }
                    }
                 );&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The second is a break at the end to keep our console window open (lines 41 and 42).&amp;#160; Hitting F5 from our project results in the following output (as expected).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_44.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroducingtheWF4Designer_12E40/image_thumb_21.png" width="550" height="381" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This concludes our brief tour through the new WF designer.&amp;#160; I’ll be talking a lot more in upcoming days about some of the more programmatic aspects of it and how it’s put together. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9632833" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/CobffhheRhg" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="vNext" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vNext/default.aspx" /><category term="vs10" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vs10/default.aspx" /><category term="wf4" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx" /><category term="beta" scheme="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/05/20/introducing-the-wf4-designer.aspx</feedburner:origLink></entry><entry><title>10-4 Good Buddy, First Look at WF 4</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/R9LParzXdYw/10-4-good-buddy-first-look-at-wf-4.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/04/16/10-4-good-buddy-first-look-at-wf-4.aspx</id><published>2009-04-16T20:30:33Z</published><updated>2009-04-16T20:30:33Z</updated><content type="html">&lt;p&gt;Our WF evangelist, &lt;a href="http://blogs.msdn.com/rjacobs/" target="_blank"&gt;Ron Jacobs&lt;/a&gt;, just posted a &lt;a href="http://channel9.msdn.com/shows/10-4/10-4-Episode-16-Windows-Workflow-4/" target="_blank"&gt;10-4 screencast&lt;/a&gt; that walks through WF4 as it's looking in VS 2010.&amp;#160; This is a good first look at our bits since PDC (we've changed things a little bit).&amp;#160; I really like that he takes it from a unit testing perspective.&amp;#160; There are certainly things that have been added (like WorkflowInvoker.Invoke) which will make testing activities a lot easier than the 3.0 days.&lt;/p&gt;  &lt;p&gt;Check it out, let me know if you've got feedback.&amp;#160; &lt;/p&gt;   &lt;p&gt; &lt;object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="320" height="240"&gt; &lt;param name="source" value="http://channel9.msdn.com/App_Themes/default/VideoPlayer2009_03_17.xap" /&gt; &lt;param name="initParams" value="m=http://mschnlnine.vo.llnwd.net/d1/ch9/0/2/6/5/6/4/104Episode16Workflow_2MB_ch9.wmv,autostart=false,autohide=true,showembed=true, thumbnail=http://mschnlnine.vo.llnwd.net/d1/ch9/0/2/6/5/6/4/104Episode16Workflow_large_ch9.png, postid=465620" /&gt; &lt;param name="background" value="#00FFFFFF" /&gt; &lt;a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"&gt; &lt;img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /&gt; &lt;/a&gt; &lt;/object&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9553216" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/R9LParzXdYw" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="screencasts" scheme="http://blogs.msdn.com/mwinkle/archive/tags/screencasts/default.aspx" /><category term="vNext" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vNext/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/04/16/10-4-good-buddy-first-look-at-wf-4.aspx</feedburner:origLink></entry><entry><title>WF 4.0 -- Designer Type Visibility</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/wfguy/~3/KgP9faP_oZE/wf-4-0-designer-type-visibility.aspx" /><id>http://blogs.msdn.com/mwinkle/archive/2009/02/12/wf-4-0-designer-type-visibility.aspx</id><published>2009-02-13T00:03:52Z</published><updated>2009-02-13T00:03:52Z</updated><content type="html">&lt;p&gt;One of the exercises I'm going through now is scrubbing our API and taking a hard look at types marked as public and trying to decide &amp;quot;does it really need to be public.&amp;quot;&amp;#160; While on first blush, you can    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;What I'd love to get from folks are answers to the following questions:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Were there designer types in 3.0/3.5 that were not public that caused you problems?&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;If so, why?&amp;#160; What and how did you want to use that type?&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;Were there scenarios where you found our decisions on type visibility odd, inconsistent or painful?&amp;#160; Let me know what those were.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Looking forward to your thoughts!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9415824" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/wfguy/~4/KgP9faP_oZE" height="1" width="1"/&gt;</content><author><name>mwinkle</name><uri>http://blogs.msdn.com/members/mwinkle.aspx</uri></author><category term="wf" scheme="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx" /><category term="vNext" scheme="http://blogs.msdn.com/mwinkle/archive/tags/vNext/default.aspx" /><feedburner:origLink>http://blogs.msdn.com/mwinkle/archive/2009/02/12/wf-4-0-designer-type-visibility.aspx</feedburner:origLink></entry></feed>
