<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Matt W's Windows Workflow Place : beta</title><link>http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx</link><description>Tags: beta</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>WF4 ViewStateService</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/06/wf4-viewstateservice.aspx</link><pubDate>Sun, 06 Dec 2009 01:33:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9933058</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9933058.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9933058</wfw:commentRss><description>&lt;p&gt;A comment posted by Notre asked for some more details about view state and attached property services, so I thought I would dive into those next.&amp;#160; I will follow-up in a subsequent post on the AttachedPropertyService, as there is a little bit more going on there.&lt;/p&gt;  &lt;h1&gt;Motivation&lt;/h1&gt;  &lt;p&gt;Why do I care about viewstate?&amp;#160; Well, usually it is because we want to write something down and store it for later that is not required for runtime.&amp;#160; A common example of viewstate is the position of nodes within a flowchart.&amp;#160; While not required to execute the flowchart, they are required to effectively view the flowchart.&amp;#160; &lt;/p&gt;  &lt;h1&gt;Where to write them down?&lt;/h1&gt;  &lt;p&gt;This was a question that caused a fair amount of debate on the team.&amp;#160; There are basically two places to write down things like view state in a file-based world.&amp;#160; &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;In the source document itself&lt;/li&gt;    &lt;li&gt;In a document that stays close to the source (usually referred to as a sidecar file)&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;We had customers asking for both.&amp;#160; The motivation for the first is that for things like flowchart, where I may always care about the visualization representation, I want to keep that metadata around and only deal with one element.&amp;#160; For the second, it is motivated by the reason that we want a clean source document that only describes the minimal artifact to run.&amp;#160; Now, there are certainly many stops along the spectrum (for instance, we might always want to keep annotations or source comments in the source document, and put positioning elsewhere).&amp;#160; For VS2010, we landed with a unified API to use, and we write in the source document.&amp;#160; This is something that is likely to change in future releases, as it does make things like textual diffs rather painful. &lt;/p&gt;  &lt;p&gt;So, that’s why we want to use it.&lt;/p&gt;  &lt;h1&gt;How do we use it?&lt;/h1&gt;  &lt;p&gt;We are going to create a simple activity designer that lets me write down a comment.&lt;/p&gt;  &lt;p&gt;A few simple steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a new VS Project, let’s create an Activity Library&lt;/li&gt;    &lt;li&gt;Add a Designer to that activity library &lt;/li&gt;    &lt;li&gt;Add an attribute to the activity pointing to the designer&lt;/li&gt;    &lt;li&gt;Add a new WorkflowConsoleApp Project&lt;/li&gt;    &lt;li&gt;Build&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4WorkflowViewStateServiceandAttachedPr_13D08/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/WF4WorkflowViewStateServiceandAttachedPr_13D08/image_thumb_2.png" width="256" height="421" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now, let’s go and make our activity designer a little interesting.&lt;/p&gt;  &lt;p&gt;Let’s add a text box and a button.&amp;#160; We’ll make the text of the button something obvious like “commit comment” The XAML for the activity designer looks 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;sap:ActivityDesigner&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;simpleActivity.CommentingDesigner&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:sap&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation&amp;quot;&lt;/span&gt;
    &lt;span class="attr"&gt;xmlns:sapv&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation&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;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;stackPanel1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Top&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;TextBox&lt;/span&gt;  &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;commentBlock&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;Button&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Load View State&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;loadViewState&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;loadViewState_Click&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;Button&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Commit View State&amp;quot;&lt;/span&gt;  &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;button1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Click&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;button1_Click&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;StackPanel&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;sap:ActivityDesigner&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, let’s add some code to the button (and to the initialization of the form) &lt;/p&gt;

&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.view.viewstateservice_members(VS.100).aspx"&gt;ViewStateService&lt;/a&gt; has a few useful methods on it.&amp;#160; I want to call out a subtle difference.&amp;#160; You will see &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.view.viewstateservice.storeviewstate(VS.100).aspx"&gt;StoreViewState&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.view.viewstateservice.storeviewstatewithundo(VS.100).aspx"&gt;StoreViewStateWithUndo&lt;/a&gt;.&amp;#160; The primary distinction as the name implies is that one will simply write the view state down and will bypass the undo/redo stack.&amp;#160; This is for view state like an expanded/collapsed view.&amp;#160; You don’t really want ctl-z to simply flip expanded versus collapsed for you.&amp;#160; But for something like flowchart, where changing some of the viewstate, like position, might be such a thing that you want support for undoing the action.&amp;#160; That’s the primary difference.&lt;/p&gt;

&lt;p&gt;So, our code for the button looks like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; button1_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
{
    ViewStateService vss = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Context.Services.GetService&amp;lt;ViewStateService&amp;gt;();
    vss.StoreViewStateWithUndo(&lt;span class="kwrd"&gt;this&lt;/span&gt;.ModelItem, &lt;span class="str"&gt;&amp;quot;comment&amp;quot;&lt;/span&gt;, commentBlock.Text);
}&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, on load, we want to be able to populate the value, so we will use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.view.viewstateservice.retrieveviewstate(VS.100).aspx"&gt;RetrieveViewState&lt;/a&gt; method in order to extract this.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; loadViewState_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)
{
    ViewStateService vss = &lt;span class="kwrd"&gt;this&lt;/span&gt;.Context.Services.GetService&amp;lt;ViewStateService&amp;gt;();
    commentBlock.Text = vss.RetrieveViewState(&lt;span class="kwrd"&gt;this&lt;/span&gt;.ModelItem, &lt;span class="str"&gt;&amp;quot;comment&amp;quot;&lt;/span&gt;) &lt;span class="kwrd"&gt;as&lt;/span&gt; &lt;span class="kwrd"&gt;string&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, let’s go back to our workflow project and put an instance of this activity on the surface: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4WorkflowViewStateServiceandAttachedPr_13D08/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/WF4WorkflowViewStateServiceandAttachedPr_13D08/image_thumb.png" width="242" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Let’s add some viewstate information and commit it.&amp;#160; Now let’s look at the XAML:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;s4:NotRealInterestingActivity&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{x:Null}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;sap:VirtualizedContainerService&lt;/span&gt;.&lt;span class="attr"&gt;HintSize&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;200,99&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;sap:WorkflowViewStateService.ViewState&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;scg3:Dictionary&lt;/span&gt; &lt;span class="attr"&gt;x:TypeArguments&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;x:String, x:Object&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;x:String&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;comment&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;basic comment&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;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;scg3:Dictionary&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;sap:WorkflowViewStateService.ViewState&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;s4:NotRealInterestingActivity&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;Ok, now, to show that we can pull this in, let’s change the text in the xaml and then reload our designer. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4WorkflowViewStateServiceandAttachedPr_13D08/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/WF4WorkflowViewStateServiceandAttachedPr_13D08/image_thumb_1.png" width="244" height="224" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;

&lt;p&gt;You can muck around with ctl-z to see that this does get handled correctly via the undo.&amp;#160; &lt;/p&gt;

&lt;p&gt;The other important thing to note is that this takes an object, so your viewstate is not limited to strings, you can have more full featured objects if you’d like. Finally, the ViewStateService also has a &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.view.viewstateservice.viewstatechanged(VS.100).aspx"&gt;ViewStateChanged&lt;/a&gt; you can subscribe to in order to handle, dispatch, and react to view state changes in the designer. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9933058" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/designer/default.aspx">designer</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category></item><item><title>Where is System.Activities.Design in WF4 Beta2 and Beyond?</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/05/where-is-system-activities-design-in-wf4-beta2-and-beyond.aspx</link><pubDate>Sat, 05 Dec 2009 23:40:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9933046</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9933046.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9933046</wfw:commentRss><description>&lt;p&gt;I got an email over the weekend asking about this, and I realized that it’s somewhat buried in this post &lt;a href="http://blogs.msdn.com/mwinkle/archive/2009/10/20/wf4-designer-enhancements-in-vs-2010-beta-2.aspx"&gt;here&lt;/a&gt;.&amp;#160; Anyway, in Beta1, you often saw System.Activities.Design.&amp;#160; For beta2 (and RTM), one important change&lt;/p&gt;  &lt;h3&gt;System.Activities.Design&amp;#160; =&amp;gt; System.Activities.Presentation&lt;/h3&gt;  &lt;p&gt;The primary reason for this change is that the *.Design suffix is generally reserved for VS design extensibility.&amp;#160; As our designer ships in the framework, *.Design was not the correct suffix.&amp;#160; *.Presentation is where we landed.&amp;#160; &lt;/p&gt;  &lt;p&gt;Hoping that putting this in the title lands this high up in search queries so that this post might be useful for a few people.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9933046" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category></item><item><title>Finding the Variables in Scope Within the WF Designer</title><link>http://blogs.msdn.com/mwinkle/archive/2009/11/06/finding-the-variables-in-scope-within-the-wf-designer.aspx</link><pubDate>Fri, 06 Nov 2009 06:21:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918399</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9918399.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9918399</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/activities/default.aspx">activities</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx">vs2010</category></item><item><title>WF4 Beta1 =&gt; Beta2 Breaking Changes Document Published</title><link>http://blogs.msdn.com/mwinkle/archive/2009/11/02/wf4-beta1-beta2-breaking-changes-document-published.aspx</link><pubDate>Mon, 02 Nov 2009 05:24:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916032</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9916032.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9916032</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx">vs2010</category></item><item><title>Types, Metatypes and Bears, Redux</title><link>http://blogs.msdn.com/mwinkle/archive/2009/10/23/types-metatypes-and-bears-redux.aspx</link><pubDate>Fri, 23 Oct 2009 16:16:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9912121</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9912121.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9912121</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Workflow/default.aspx">Workflow</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/designer/default.aspx">designer</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/xaml/default.aspx">xaml</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx">vs2010</category></item><item><title>Navigating the WF4 Beta 2 Samples</title><link>http://blogs.msdn.com/mwinkle/archive/2009/10/22/navigating-the-wf4-beta-2-samples.aspx</link><pubDate>Thu, 22 Oct 2009 19:25:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9911620</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9911620.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9911620</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Workflow/default.aspx">Workflow</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx">vs2010</category></item><item><title>WF4 Designer Enhancements in VS 2010 Beta 2</title><link>http://blogs.msdn.com/mwinkle/archive/2009/10/20/wf4-designer-enhancements-in-vs-2010-beta-2.aspx</link><pubDate>Tue, 20 Oct 2009 17:10:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9910043</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9910043.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9910043</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vs2010/default.aspx">vs2010</category></item><item><title>Introducing the WF4 Designer</title><link>http://blogs.msdn.com/mwinkle/archive/2009/05/20/introducing-the-wf4-designer.aspx</link><pubDate>Wed, 20 May 2009 23:27:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9632833</guid><dc:creator>mwinkle</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9632833.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9632833</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vNext/default.aspx">vNext</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/vs10/default.aspx">vs10</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/beta/default.aspx">beta</category></item></channel></rss>