<?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 : wf4</title><link>http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx</link><description>Tags: wf4</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Swiss Cheese and WF4, or, An Introduction to ActivityAction</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/24/swiss-cheese-and-wf4-or-an-introduction-to-activityaction.aspx</link><pubDate>Thu, 24 Dec 2009 01:46:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9940807</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9940807.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9940807</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://www.flickr.com/photos/myklroventine/497322721/"&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="swiss cheese" border="0" alt="swiss cheese" align="right" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/SwissCheeseandWF4UsingActivityAction_150D8/swiss%20cheese_3.jpg" width="217" height="298" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One common scenario that was often requested by customers of WF 3 was the ability to have templated or “grey box” or “activities with holes” in them (hence the Swiss cheese photo above).&amp;#160; In WF4 we’ve done this in a way that way we call &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.activityaction(VS.100).aspx"&gt;ActivityAction&lt;/a&gt;&lt;/p&gt;  &lt;h1&gt;Motivation&lt;/h1&gt;  &lt;p&gt;First I’d like to do a little bit more to motivate the scenario.&amp;#160; &lt;/p&gt;  &lt;p&gt;Consider an activity that you have created for your ERP system called CheckInventory.&amp;#160; You’ve gone ahead and encapsulated all of the logic of your inventory system, maybe you have some different paths of logic, maybe you have interactions with some third party systems, but you want your customers to use this activity in their workflows when they need to get the level of inventory for an item.&amp;#160; &lt;/p&gt;  &lt;p&gt;Consider more generally an activity where you have a bunch of work you want to get done, but at various, and specific, points throughout that work, you want to allow the consumer of that activity to receive a callback and provide their own logic to handle that.&amp;#160; The mental model here is one of delegates.&lt;/p&gt;  &lt;p&gt;Finally, consider providing the ability for a user to specify the work that they want to have happen, but also make sure that you can strongly type the data that is passed to it.&amp;#160; In the first case above, you want to make sure that the Item in question is passed to the action that the consumer supplies.&amp;#160; &lt;/p&gt;  &lt;p&gt;In wf3, we had a lot of folks want to be able to do something like this. It’s a very natural extension to wanting to model things as activities and composing into higher level activities.&amp;#160; We like being able to string together 10 items as a black box for reuse, but we really want the user to specify exactly what should happen between steps 7 and 8.&amp;#160; &lt;/p&gt;  &lt;p&gt;A slide that I showed at PDC showed it this way (the Approval and Payment boxes represent the places I want a consumer to supply additional logic):&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/SwissCheeseandWF4UsingActivityAction_150D8/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/SwissCheeseandWF4UsingActivityAction_150D8/image_thumb_1.png" width="486" height="360" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Introducing ActivityAction&lt;/h2&gt;  &lt;p&gt;Very early on the release, we knew this was one of the problems that we needed to tackle. The mental model that we are most aligned with is that of a delegate/ callback in C#.&amp;#160; If you think about a delegate, what are you doing, you are giving an object the implementation of some bit of logic that the object will subsequently call.&amp;#160; That’s the same thing that’s going on with an ActivityAction.&amp;#160; there are three important parts to an ActivityAction&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The Handler (this is the logic of the ActivityAction) &lt;/li&gt;    &lt;li&gt;The Shape (this determines the data that will be passed to the handler) &lt;/li&gt;    &lt;li&gt;The way that we invoke it from our activity &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Let’s start with some simple code (this is from a demo that I showed in my PDC &lt;a href="http://microsoftpdc.com/sessions/ft17"&gt;talk&lt;/a&gt;).&amp;#160; This is a timer activity which allows us to time the execution for the contained activity and then uses an activity action to act on the result.&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Diagnostics;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; CustomActivities.ActivityTypes&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&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; Timer : NativeActivity&amp;lt;TimeSpan&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Activity Body { get; set; }&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Variable&amp;lt;Stopwatch&amp;gt; Stopwatch { get; set; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; ActivityAction&amp;lt;TimeSpan&amp;gt; OnCompletion { get; set; }&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Timer()&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            Stopwatch = &lt;span class="kwrd"&gt;new&lt;/span&gt; Variable&amp;lt;Stopwatch&amp;gt;();&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&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; CacheMetadata(NativeActivityMetadata metadata)&lt;/pre&gt;

  &lt;pre class="alt"&gt;        {&lt;/pre&gt;

  &lt;pre&gt;            metadata.AddImplementationVariable(Stopwatch);&lt;/pre&gt;

  &lt;pre class="alt"&gt;            metadata.AddChild(Body);&lt;/pre&gt;

  &lt;pre&gt;            metadata.AddDelegate(OnCompletion);&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&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(NativeActivityContext context)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            Stopwatch sw = &lt;span class="kwrd"&gt;new&lt;/span&gt; Stopwatch();&lt;/pre&gt;

  &lt;pre&gt;            Stopwatch.Set(context, sw);&lt;/pre&gt;

  &lt;pre class="alt"&gt;            sw.Start();&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="rem"&gt;// schedule body and completion callback&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            context.ScheduleActivity(Body, Completed);&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Completed(NativeActivityContext context, ActivityInstance instance)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!context.IsCancellationRequested)&lt;/pre&gt;

  &lt;pre&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;                Stopwatch sw = Stopwatch.Get(context);&lt;/pre&gt;

  &lt;pre&gt;                sw.Stop();&lt;/pre&gt;

  &lt;pre class="alt"&gt;                Result.Set(context, sw.Elapsed);&lt;/pre&gt;

  &lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (OnCompletion != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;                {&lt;/pre&gt;

  &lt;pre&gt;                    context.ScheduleAction&amp;lt;TimeSpan&amp;gt;(OnCompletion, Result.Get(context));&lt;/pre&gt;

  &lt;pre class="alt"&gt;                }&lt;/pre&gt;

  &lt;pre&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre class="alt"&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; Cancel(NativeActivityContext context)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            context.CancelChildren();&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (OnCompletion != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;            {&lt;/pre&gt;

  &lt;pre&gt;                context.ScheduleAction&amp;lt;TimeSpan&amp;gt;(OnCompletion, TimeSpan.MinValue);&lt;/pre&gt;

  &lt;pre class="alt"&gt;            }&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&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;A few things to note about this code sample:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The declaration of an ActivityAction&amp;lt;TimeSpan&amp;gt; as a member of the activity.&amp;#160; You’ll note we use the OnXXX convention often for activity actions. &lt;/li&gt;

  &lt;li&gt;The usage of the &lt;a href="http://msdn.microsoft.com/en-us/library/dd485397(VS.100).aspx"&gt;ActivityAction&amp;lt;T&amp;gt;&lt;/a&gt; with on type argument.&amp;#160; The way to read this, or any of the 15 other types is that the T is the type of the data that will be passed to the activity action’s handler. 

    &lt;ul&gt;
      &lt;li&gt;Think about this like an Activity&amp;lt;Foo&amp;gt; corresponding to a void DoSomething(Foo argument1) method &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;The call to &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.nativeactivitymetadata.adddelegate(VS.100).aspx"&gt;NativeActivityMetadata.AddDelegate()&lt;/a&gt; which lets the runtime know that it needs to worry about the delegate &lt;/li&gt;

  &lt;li&gt;The code in the Completed( ) method which checks to see if OnCompletion is set and then schedules it using &lt;a href="http://msdn.microsoft.com/en-us/library/dd987734(VS.100).aspx"&gt;ScheduleAction&lt;/a&gt;.&amp;#160; I want to call out that line of code. &lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (OnCompletion != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
{
    context.ScheduleAction&amp;lt;TimeSpan&amp;gt;(OnCompletion, Result.Get(context));
}&lt;/pre&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;It is important to note that I use the second parameter (and the third through 16th if that version is provided) in order to provide the data.&amp;#160; This way, the activity determines what data will be passed to the handler, allowing the activity to determine what data is visible where.&amp;#160; This is a much better way than allowing an invoked child to access any and all data from the parent.&amp;#160; This lets us be very specific about what data goes to the ActivityAction.&amp;#160;&amp;#160; Also, you could make it so that OnCompletion must be provided, that is, the only way to use the activity is to supply an implementation.&amp;#160; If you have something like “ProcessPayment” you likely want that to be a required thing.&amp;#160; You can use the CacheMetadata method in order to check and validate this. &lt;/p&gt;

&lt;p&gt;Now, let’s look at the code required to consume this time activity:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;DelegateInArgument&amp;lt;TimeSpan&amp;gt; time = &lt;span class="kwrd"&gt;new&lt;/span&gt; DelegateInArgument&amp;lt;TimeSpan&amp;gt;();
a = &lt;span class="kwrd"&gt;new&lt;/span&gt; Timer
{
    Body = &lt;span class="kwrd"&gt;new&lt;/span&gt; HttpGet { Url = &lt;span class="str"&gt;&amp;quot;http://www.microsoft.com&amp;quot;&lt;/span&gt; },
    OnCompletion = &lt;span class="kwrd"&gt;new&lt;/span&gt; ActivityAction&amp;lt;TimeSpan&amp;gt;
    {
        Argument = time,
        Handler = &lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine { 
            Text = &lt;span class="kwrd"&gt;new&lt;/span&gt; InArgument&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;(
                ctx =&amp;gt; 
                    &lt;span class="str"&gt;&amp;quot;Time input from timer &amp;quot;&lt;/span&gt; + time.Get(ctx).TotalMilliseconds)
        } 

    }
};&lt;/pre&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;There are a couple of interesting things here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Creation of &lt;a href="http://msdn.microsoft.com/en-us/library/dd987988(VS.100).aspx"&gt;DelegateInArgument&lt;/a&gt;&amp;lt;TimeSpan&amp;gt; : This is used to represent the data passed by the ActivityAction to the handler &lt;/li&gt;

  &lt;li&gt;Creation of the ActivityAction to pass in.&amp;#160; You’ll note that the &lt;a href="http://msdn.microsoft.com/en-us/library/dd486711(VS.100).aspx"&gt;Argument&lt;/a&gt; property is set to the DelegateInArgument, which we can then use in the handler &lt;/li&gt;

  &lt;li&gt;The H&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.activitydelegate.handler(VS.100).aspx"&gt;andler&lt;/a&gt; is the “implementation” that we want to invoke.&amp;#160; here’s it’s pretty simple, it’s a WriteLine and when we construct the argument we construct if from a lambda that uses the passed in context to resolve the DelegateInArgument when that executes. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At runtime, when we get to the point in the execution of the Timer activity, the WriteLine that the hosting app provided will be scheduled when the ScheduleAction is called.&amp;#160; This means we will output the timing information that the Timer observed.&amp;#160; A different implementation could have an IfThen activity and use that to determine if an SLA was enforced or not, and if not, send a nasty email to the WF author.&amp;#160; The possibilities are endless, and they open up scenarios for you to provide specific extension points for your activities.&lt;/p&gt;

&lt;p&gt;That wraps up a very brief tour of ActivityAction.&amp;#160; ActivityAction provides a easy way to create an empty place in activity that the consumer can use to supply the logic that they want executed.&amp;#160; In the second part of this post, we’ll dive into how to create a designer for one of these, how to represent this in XAML, and a few other interesting topics. &lt;/p&gt;

&lt;p&gt;It’s that time of year that I’ll be taking a little bit of time off for the holidays, so I will see y’all in 2010! &lt;/p&gt;

&lt;p&gt;Photo Credit &lt;/p&gt;

&lt;div about="http://www.flickr.com/photos/myklroventine/497322721/" xmlns:cc="http://creativecommons.org/ns#"&gt;&lt;a href="http://www.flickr.com/photos/myklroventine/" rel="cc:attributionURL"&gt;http://www.flickr.com/photos/myklroventine/&lt;/a&gt; / &lt;a href="http://creativecommons.org/licenses/by/2.0/" rel="license"&gt;CC BY 2.0&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9940807" 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/ActivityModel/default.aspx">ActivityModel</category></item><item><title>Inspection, Default Services and Items (WF4 EditingContext Intro Part 6)</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/23/inspection-default-services-and-items-wf4-editingcontext-intro-part-6.aspx</link><pubDate>Wed, 23 Dec 2009 01:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9940348</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9940348.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9940348</wfw:commentRss><description>
&lt;STYLE id=toolsplat_features_updated_29733_Styles&gt;






&lt;!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
.xl1529733
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:general;
	text-align:general;
	vertical-align:bottom;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6529733
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:#006100;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:general;
	text-align:general;
	vertical-align:bottom;
	background:#c6efce;
	mso-pattern:black none;
	white-space:nowrap;}
.xl6629733
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:#9c0006;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:general;
	text-align:general;
	vertical-align:bottom;
	background:#ffc7ce;
	mso-pattern:black none;
	white-space:nowrap;}
--&gt;&lt;/STYLE&gt;

&lt;STYLE id=toolsplat_features_updated_16386_Styles&gt;







&lt;!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
.xl1516386
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:general;
	text-align:general;
	vertical-align:bottom;
	mso-background-source:auto;
	mso-pattern:auto;
	white-space:nowrap;}
.xl6516386
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:#006100;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:general;
	text-align:general;
	vertical-align:bottom;
	background:#c6efce;
	mso-pattern:black none;
	white-space:nowrap;}
.xl6616386
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:#9c0006;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:calibri, sans-serif;
	mso-font-charset:0;
	mso-number-format:general;
	text-align:general;
	vertical-align:bottom;
	background:#ffc7ce;
	mso-pattern:black none;
	white-space:nowrap;}
--&gt;&lt;/STYLE&gt;

&lt;P&gt;This part 6 of my 6&amp;nbsp; part series on the EditingContext.&lt;/P&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/12/21/introduction-to-the-wf4-designer-editing-context-part-1.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/12/21/introduction-to-the-wf4-designer-editing-context-part-1.aspx"&gt;Introduction&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/12/21/sharing-functionality-between-designers-wf4-editingcontext-intro-part-2.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/12/21/sharing-functionality-between-designers-wf4-editingcontext-intro-part-2.aspx"&gt;Sharing Functionality between Designers&lt;/A&gt;&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/12/22/host-provided-capabilities-wf4-editingcontext-intro-part-3.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/12/22/host-provided-capabilities-wf4-editingcontext-intro-part-3.aspx"&gt;Host provided capabilities&lt;/A&gt;&amp;nbsp;&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/12/22/providing-callbacks-for-the-host-wf4-editingcontext-intro-part-4.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/12/22/providing-callbacks-for-the-host-wf4-editingcontext-intro-part-4.aspx"&gt;Providing callbacks for the host&lt;/A&gt;&amp;nbsp; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/12/22/subscription-notification-engine-wf4-editingcontext-intro-part-5.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/12/22/subscription-notification-engine-wf4-editingcontext-intro-part-5.aspx"&gt;Subscription/Notification engine&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mwinkle/archive/2009/12/23/inspection-default-services-and-items-wf4-editingcontext-intro-part-6.aspx" mce_href="http://blogs.msdn.com/mwinkle/archive/2009/12/23/inspection-default-services-and-items-wf4-editingcontext-intro-part-6.aspx"&gt;Inspection, Default Services and Items (you are here)&lt;/A&gt; 
&lt;P&gt;I want to wrap up this series of posts by posting some code for an activity designer that functions more as a diagnostic tool, and will display all of the Items and services of the EditingContext within the designer.&amp;nbsp; This will be useful from an investigation perspective, and hopefully as a diagnostic tool.&amp;nbsp; We will use this to help us understand what are the services that are available out of the box in VS, as well as in a rehosted application.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;We first need to create an empty activity to attach a designer to.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Collections.Generic;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Linq;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Text;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Activities;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.ComponentModel;

&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; blogEditingContext
{
    [Designer(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(DiagnosticDesigner))]
    &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; Diagnosticator : CodeActivity
    {
        &lt;SPAN class=rem&gt;// Define an activity input argument of type string&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;SPAN class=rem&gt;// If your activity returns a value, derive from CodeActivity&amp;lt;TResult&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=rem&gt;// and return the value from the Execute method.&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;SPAN class=rem&gt;// Obtain the runtime value of the Text input argument&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; text = context.GetValue(&lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.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, let’s create our designer.&amp;nbsp; We could do fancy treeviews or object browser style UI’s, but as this is a blog post, I want to provide you with the basics, and then let you figure out how that is most useful to you.&amp;nbsp; So, we will just create a designer that writes out to debug output the relevant information.&amp;nbsp; &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;sap:ActivityDesigner&lt;/SPAN&gt; &lt;SPAN class=attr&gt;x:Class&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="blogEditingContext.DiagnosticDesigner"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:sap&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"&lt;/SPAN&gt;
    &lt;SPAN class=attr&gt;xmlns:sapv&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"&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;Button&lt;/SPAN&gt; &lt;SPAN class=attr&gt;Click&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Button_Click"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;Debug.WriteLine Context Data&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;Button&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;And now the code&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Diagnostics;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Linq;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Windows;

&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; blogEditingContext
{
    &lt;SPAN class=rem&gt;// Interaction logic for DiagnosticDesigner.xaml&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;partial&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; DiagnosticDesigner
    {
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; DiagnosticDesigner()
        {
            InitializeComponent();
        }

        &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; Button_Click(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, RoutedEventArgs e)
        {
            &lt;SPAN class=rem&gt;// the goal here is to output meaningful and useful information about &lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;// the contents of the editing context here. &lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; level = Debug.IndentLevel;
            Debug.WriteLine(&lt;SPAN class=str&gt;"Items in the EditingContext"&lt;/SPAN&gt;);
            Debug.IndentLevel++;
            &lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; (var item &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; Context.Items.OrderBy(x =&amp;gt; x.ItemType.ToString()))
            {
                Debug.WriteLine(item.ItemType);
            }

            Debug.IndentLevel = level;
            Debug.WriteLine(&lt;SPAN class=str&gt;"Services in the EditingContext"&lt;/SPAN&gt;);
            &lt;SPAN class=kwrd&gt;foreach&lt;/SPAN&gt; (var service &lt;SPAN class=kwrd&gt;in&lt;/SPAN&gt; Context.Services.OrderBy(x =&amp;gt; x.ToString()))
            {
                Debug.WriteLine(service);
            }
        }
    }
}&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;Let’s break this down.&amp;nbsp; The work here happens in the button click where we simply order by types’ string representations and output them to the debug writer (a more robust implementation might use a trace writer that could be configured in the app, but for this purpose, this will be sufficient. &lt;/P&gt;
&lt;P&gt;So, what output do we get?&lt;/P&gt;
&lt;H1&gt;&lt;/H1&gt;
&lt;H1&gt;VS Standard Services and Items&lt;/H1&gt;
&lt;P&gt;We determine this by using the activity in a freshly opened WF project&lt;/P&gt;
&lt;H2&gt;Items&lt;/H2&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width=64&gt;System.Activities.Presentation.Hosting.AssemblyContextControlItem&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.ReadOnlyState&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.WorkflowCommandExtensionItem&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.Selection&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.WorkflowFileItem&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;H2&gt;Services&lt;/H2&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width=64&gt;System.Activities.Presentation.Debug.IDesignerDebugView&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.DesignerPerfEventProvider&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.FeatureManager&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.ICommandService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.IMultiTargetingSupportService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.WindowHelperService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.IActivityToolboxService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.IIntegratedHelpService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.IWorkflowDesignerStorageService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.IXamlLoadErrorService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Model.AttachedPropertiesService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Model.ModelTreeManager&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Services.ModelService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Services.ViewService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.UndoEngine&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Validation.IValidationErrorService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Validation.ValidationService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.ActivityTypeDesigner+DisplayNameUpdater&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.DesignerView&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.IExpressionEditorService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.ViewStateService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.VirtualizedContainerService&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;&lt;/H1&gt;
&lt;H1&gt;Basic Rehosted Application Standard Services and Items&lt;/H1&gt;
&lt;H2&gt;Items&lt;/H2&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width=64&gt;System.Activities.Presentation.Hosting.ReadOnlyState&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.WorkflowCommandExtensionItem&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.Selection&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;H2&gt;Services&lt;/H2&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width=64&gt;System.Activities.Presentation.DesignerPerfEventProvider&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.FeatureManager&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Hosting.WindowHelperService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Model.AttachedPropertiesService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Model.ModelTreeManager&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Services.ModelService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Services.ViewService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.UndoEngine&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.Validation.ValidationService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.DesignerView&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.ViewStateService&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;System.Activities.Presentation.View.VirtualizedContainerService&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;H1&gt;Comparison Table View&lt;/H1&gt;
&lt;DIV align=center x:publishsource="Excel"&gt;
&lt;TABLE style="WIDTH: 507pt; BORDER-COLLAPSE: collapse; TABLE-LAYOUT: fixed" border=0 cellSpacing=0 cellPadding=0 width=676&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 396pt; mso-width-source: userset; mso-width-alt: 19309" width=528&gt;
&lt;COL style="WIDTH: 48pt" width=64&gt;
&lt;COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 3072" width=84&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; WIDTH: 396pt; FONT-FAMILY: calibri; BACKGROUND: #4f81bd; HEIGHT: 15pt; COLOR: white; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 700; TEXT-DECORATION: none; mso-pattern: #4f81bd none; text-underline-style: none; text-line-through: none" class=xl1529733 height=20 width=528 align=left class="xl1529733"&gt;Items&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; WIDTH: 48pt; FONT-FAMILY: calibri; BACKGROUND: #4f81bd; COLOR: white; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 700; TEXT-DECORATION: none; mso-pattern: #4f81bd none; text-underline-style: none; text-line-through: none" class=xl1529733 width=64 align=left class="xl1529733"&gt;VS&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; WIDTH: 63pt; FONT-FAMILY: calibri; BACKGROUND: #4f81bd; COLOR: white; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 700; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: #4f81bd none; text-underline-style: none; text-line-through: none" class=xl1529733 width=84 align=left class="xl1529733"&gt;Rehosted&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1529733 height=20 align=left class="xl1529733"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Hosting.AssemblyContextControlItem&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6629733 align=left class="xl6629733"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1529733 height=20 align=left class="xl1529733"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Hosting.ReadOnlyState&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1529733 height=20 align=left class="xl1529733"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Hosting.WorkflowCommandExtensionItem&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1529733 height=20 align=left class="xl1529733"&gt;
&lt;P align=left&gt;System.Activities.Presentation.View.Selection&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 0.5pt solid; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1529733 height=20 align=left class="xl1529733"&gt;
&lt;P align=left&gt;System.Activities.Presentation.WorkflowFileItem&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6529733 align=left class="xl6529733"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 0.5pt solid; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6629733 align=left class="xl6629733"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;DIV align=center x:publishsource="Excel"&gt;
&lt;TABLE style="WIDTH: 507pt; BORDER-COLLAPSE: collapse; TABLE-LAYOUT: fixed" border=0 cellSpacing=0 cellPadding=0 width=676&gt;
&lt;COLGROUP&gt;
&lt;COL style="WIDTH: 396pt; mso-width-source: userset; mso-width-alt: 19309" width=528&gt;
&lt;COL style="WIDTH: 48pt" width=64&gt;
&lt;COL style="WIDTH: 63pt; mso-width-source: userset; mso-width-alt: 3072" width=84&gt;&lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; WIDTH: 396pt; FONT-FAMILY: calibri; BACKGROUND: #4f81bd; HEIGHT: 15pt; COLOR: white; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 700; TEXT-DECORATION: none; mso-pattern: #4f81bd none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 width=528 class="xl1516386"&gt;Services&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; WIDTH: 48pt; FONT-FAMILY: calibri; BACKGROUND: #4f81bd; COLOR: white; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 700; TEXT-DECORATION: none; mso-pattern: #4f81bd none; text-underline-style: none; text-line-through: none" class=xl1516386 width=64 class="xl1516386"&gt;VS&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; WIDTH: 63pt; FONT-FAMILY: calibri; BACKGROUND: #4f81bd; COLOR: white; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 700; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: #4f81bd none; text-underline-style: none; text-line-through: none" class=xl1516386 width=84 class="xl1516386"&gt;Rehosted&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Debug.IDesignerDebugView&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.DesignerPerfEventProvider&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.FeatureManager&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Hosting.ICommandService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Hosting.IMultiTargetingSupportService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Hosting.WindowHelperService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.IActivityToolboxService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.IIntegratedHelpService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.IWorkflowDesignerStorageService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.IXamlLoadErrorService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Model.AttachedPropertiesService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Model.ModelTreeManager&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Services.ModelService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Services.ViewService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.UndoEngine&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Validation.IValidationErrorService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.Validation.ValidationService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.View.ActivityTypeDesigner+DisplayNameUpdater&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.View.DesignerView&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.View.IExpressionEditorService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #ffc7ce; COLOR: #9c0006; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6616386 class="xl6616386"&gt;
&lt;P align=left&gt;No&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.View.ViewStateService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="HEIGHT: 15pt" height=20&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 0.5pt solid; BORDER-LEFT: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; HEIGHT: 15pt; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; text-underline-style: none; text-line-through: none" class=xl1516386 height=20 class="xl1516386"&gt;
&lt;P align=left&gt;System.Activities.Presentation.View.VirtualizedContainerService&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 0.5pt solid; BORDER-RIGHT-STYLE: none; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-BOTTOM: #4f81bd 0.5pt solid; FONT-FAMILY: calibri; BACKGROUND: #c6efce; COLOR: #006100; FONT-SIZE: 11pt; BORDER-LEFT-STYLE: none; BORDER-TOP: #4f81bd 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #4f81bd 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl6516386 class="xl6516386"&gt;
&lt;P align=left&gt;Yes&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;
&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;
&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;
&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;
&lt;H1&gt;Conclusion&lt;/H1&gt;
&lt;P&gt;This wraps up our series on the editing context.&amp;nbsp; We’ve gone through the basics of why we need it, what we can do with it, and then we moved how to use it, from both the very simple to the very complex.&amp;nbsp; We’ve finished with a diagnostic tool to help understand what all items I can bind to.&lt;/P&gt;
&lt;P&gt;What’s Next From Here?&lt;/P&gt;
&lt;P&gt;A few ideas for the readers who have read all of these:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Wire up a few attached properties to reflect back through to some interesting data (like if it is selected).&amp;nbsp; These attached properties could then be used directly by your UI (via the binding in XAML) to let your designers display and react to changes in the data &lt;/LI&gt;
&lt;LI&gt;Think about ideas for services you might want to add in VS without depending on an activity to inject it (and send me mail, I am trying to compile a list of interesting things) &lt;/LI&gt;
&lt;LI&gt;Are there service/item implementations you want to override in VS? &lt;/LI&gt;
&lt;LI&gt;Is there a service/item you expect to see that is not there? &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Thanks for now!&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9940348" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/mwinkle/attachment/9940348.ashx" length="22510" type="application/x-zip-compressed" /><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></item><item><title>Emitting the mc:Ignorable Instruction In Your WF4 XAML</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/10/emitting-the-mc-ignorable-instruction-in-your-wf4-xaml.aspx</link><pubDate>Thu, 10 Dec 2009 21:33:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9935376</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9935376.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9935376</wfw:commentRss><description>&lt;p&gt;Frequent forum guest Notre posed this &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/e60b68f8-e3d2-46bf-aa70-7280853cd3f5"&gt;question&lt;/a&gt; to the forums the other day noting that the XAML being produced from &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.xamlintegration.activityxamlservices.createbuilderwriter(VS.100).aspx"&gt;ActivityXamlServices.CreateBuilderWriter()&lt;/a&gt; was slightly different than the XAML being output from &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.workflowdesigner.save(VS.100).aspx"&gt;WorkflowDesigner.Save().&lt;/a&gt;&amp;#160; The reason for this stems from the fact that WorkflowDesigner leverages an additional internal type (which derives from XamlXmlWriter) in order to attach the mc:Ignorable attribute.&amp;#160; &lt;/p&gt;  &lt;h1&gt;Why use mc:Ignorable?&lt;/h1&gt;  &lt;p&gt;From the &lt;a href="http://msdn.microsoft.com/en-us/library/aa350024.aspx"&gt;source&lt;/a&gt; at MSDN:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;The mc XML namespace prefix is the recommended prefix convention to use when mapping the XAML compatibility namespace http://schemas.openxmlformats.org/markup-compatibility/2006.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Elements or attributes where the prefix portion of the element name are identified as mc:Ignorable will not raise errors when processed by a XAML processor. If that attribute could not be resolved to an underlying type or programming construct, then that element is ignored. Note however that ignored elements might still generate additional parsing errors for additional element requirements that are side effects of that element not being processed. For instance, a particular element content model might require exactly one child element, but if the specified child element was in an mc:Ignorable prefix, and the specified child element could not be resolved to a type, then the XAML processor might raise an error.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Basically, this lets a XAML reader gracefully ignore any content marked from that namespace if it cannot be resolved.&amp;#160; So, imagine a runtime scenario where we don’t want to load System.Activities.Presentation every time we read a WF XAML file that may contain viewstate.&amp;#160; As a result, we use mc:Ignorable, which means the reader will skip that content when it does not have that assembly referenced at runtime.&amp;#160; &lt;/p&gt;  &lt;p&gt;This is what the output from the designer usually contains:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Sequence&lt;/span&gt; 
     &lt;span class="attr"&gt;mc:Ignorable&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;sap&amp;quot;&lt;/span&gt; 
     &lt;span class="attr"&gt;mva:VisualBasic&lt;/span&gt;.&lt;span class="attr"&gt;Settings&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Assembly references and imported namespaces serialized as XML namespaces&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/netfx/2009/xaml/activities&amp;quot;&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;span class="attr"&gt;xmlns:mva&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities&amp;quot;&lt;/span&gt; 
     &lt;span class="attr"&gt;xmlns:sap&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation&amp;quot;&lt;/span&gt; 
     &lt;span class="attr"&gt;xmlns:scg&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System.Collections.Generic;assembly=mscorlib&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="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;scg: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:Boolean&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;IsExpanded&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;True&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;x:Boolean&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;scg: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;Persist&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;211,22&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;Persist&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;211,22&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;WriteLine&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;211,61&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;Sequence&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;mc:Ignorable will cause the ViewState and HintSize to be ignored. &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;Why do I have to worry about this?&lt;/h1&gt;

&lt;p&gt;If you use WorkflowDesigner.Save(), you don’t.&amp;#160; If you want to be able to serialize the ActivityBuilder and have XAML which is what the designer produces, you need will need to add a XamlXmlWriter into the XamlWriter stack in order to get the right output. You may also worry about this if you are implementing your own storage and plan on writing some additional XAML readers or writers for additional extensibility and flexibility.&lt;/p&gt;

&lt;h1&gt;How Do I Get the Same Behavior?&lt;/h1&gt;

&lt;p&gt;The code below describes the same approach you would need to take to implement an XamlXmlWriter that does the same thing our internal type does.&amp;#160; While I can’t copy and paste code, this does the same thing.&amp;#160; We do two things:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Override &lt;a title="WriteNamespace(" href="http://msdn.microsoft.com/en-us/library/system.xaml.xamlxmlwriter.writenamespace(VS.100).aspx"&gt;WriteNamespace(&lt;/a&gt;) to collect all of the namespaces being emitted.&amp;#160; We do this to specifically check for ones that we should ignore, and to also gather all of the prefixes to make sure we don’t have a collision&lt;/li&gt;

  &lt;li&gt;Override &lt;a title="WriteStartObject" href="http://msdn.microsoft.com/en-us/library/system.xaml.xamlxmlwriter.writestartobject(VS.100).aspx"&gt;WriteStartObject&lt;/a&gt;() to generate and write out the Ignorable attribute within the start (first) member for any namespaces we should ignore.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What namespaces do we ignore in the designer?&amp;#160; Just one: &lt;strong&gt;&lt;em&gt;http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xaml;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Xml;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; IgnorableXamlWriter&lt;/pre&gt;

    &lt;pre class="alt"&gt;{&lt;/pre&gt;

    &lt;pre&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; IgnorableXamlXmlWriter : XamlXmlWriter&lt;/pre&gt;

    &lt;pre class="alt"&gt;    {&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        HashSet&amp;lt;NamespaceDeclaration&amp;gt; ignorableNamespaces = &lt;span class="kwrd"&gt;new&lt;/span&gt; HashSet&amp;lt;NamespaceDeclaration&amp;gt;();&lt;/pre&gt;

    &lt;pre&gt;        HashSet&amp;lt;NamespaceDeclaration&amp;gt; allNamespaces = &lt;span class="kwrd"&gt;new&lt;/span&gt; HashSet&amp;lt;NamespaceDeclaration&amp;gt;();&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;bool&lt;/span&gt; objectWritten;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;bool&lt;/span&gt; hasDesignNamespace;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; designNamespacePrefix;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; IgnorableXamlXmlWriter(TextWriter tw, XamlSchemaContext context)&lt;/pre&gt;

    &lt;pre&gt;            : &lt;span class="kwrd"&gt;base&lt;/span&gt;(XmlWriter.Create(tw,&lt;/pre&gt;

    &lt;pre class="alt"&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlWriterSettings { Indent = &lt;span class="kwrd"&gt;true&lt;/span&gt;, OmitXmlDeclaration = &lt;span class="kwrd"&gt;true&lt;/span&gt; }),&lt;/pre&gt;

    &lt;pre&gt;                                    context,&lt;/pre&gt;

    &lt;pre class="alt"&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; XamlXmlWriterSettings { AssumeValidInput = &lt;span class="kwrd"&gt;true&lt;/span&gt; })&lt;/pre&gt;

    &lt;pre&gt;        {&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;        }&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; WriteNamespace(NamespaceDeclaration namespaceDeclaration)&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!objectWritten)&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                allNamespaces.Add(namespaceDeclaration);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// if we find one, add that to ignorable namespaces&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="rem"&gt;// the goal here is to collect all of them that might point to this&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="rem"&gt;// if you had a broader set of things to ignore, you would collect &lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="rem"&gt;// those here.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (namespaceDeclaration.Namespace == &lt;span class="str"&gt;&amp;quot;http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation&amp;quot;&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre&gt;                {&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    hasDesignNamespace = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;                    designNamespacePrefix = namespaceDeclaration.Prefix;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                }&lt;/pre&gt;

    &lt;pre&gt;            }&lt;/pre&gt;

    &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;base&lt;/span&gt;.WriteNamespace(namespaceDeclaration);&lt;/pre&gt;

    &lt;pre&gt;        }&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; WriteStartObject(XamlType type)&lt;/pre&gt;

    &lt;pre class="alt"&gt;        {&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!objectWritten)&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="rem"&gt;// we should check if we should ignore &lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (hasDesignNamespace)&lt;/pre&gt;

    &lt;pre&gt;                {&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    &lt;span class="rem"&gt;// note this is not robust as mc could naturally occur&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;                    &lt;span class="kwrd"&gt;string&lt;/span&gt; mcAlias = &lt;span class="str"&gt;&amp;quot;mc&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;this&lt;/span&gt;.WriteNamespace(&lt;/pre&gt;

    &lt;pre&gt;                        &lt;span class="kwrd"&gt;new&lt;/span&gt; NamespaceDeclaration(&lt;/pre&gt;

    &lt;pre class="alt"&gt;                            &lt;span class="str"&gt;&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre&gt;                            mcAlias)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                            );&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                }&lt;/pre&gt;

    &lt;pre&gt;            }&lt;/pre&gt;

    &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;base&lt;/span&gt;.WriteStartObject(type);&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!objectWritten)&lt;/pre&gt;

    &lt;pre class="alt"&gt;            {&lt;/pre&gt;

    &lt;pre&gt;                &lt;span class="kwrd"&gt;if&lt;/span&gt; (hasDesignNamespace)&lt;/pre&gt;

    &lt;pre class="alt"&gt;                {&lt;/pre&gt;

    &lt;pre&gt;                    XamlDirective ig = &lt;span class="kwrd"&gt;new&lt;/span&gt; XamlDirective(&lt;/pre&gt;

    &lt;pre class="alt"&gt;                        &lt;span class="str"&gt;&amp;quot;http://schemas.openxmlformats.org/markup-compatibility/2006&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre&gt;                        &lt;span class="str"&gt;&amp;quot;Ignorable&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    WriteStartMember(ig);&lt;/pre&gt;

    &lt;pre&gt;                    WriteValue(designNamespacePrefix);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                    WriteEndMember();&lt;/pre&gt;

    &lt;pre&gt;                    objectWritten = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;                }&lt;/pre&gt;

    &lt;pre&gt;            }&lt;/pre&gt;

    &lt;pre class="alt"&gt;        }&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;    }&lt;/pre&gt;

    &lt;pre&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;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;One note on the code above, it is noted that the generation of the namespace prefix “mc” is not robust.&amp;#160; In the product code we will check to see if mc1, mc2, … are available up to mc1000.&amp;#160; In that case we would then append a GUID for the ugliest XML namespace known to mankind.&amp;#160; The chance of collision up to 1000 would be a highly extreme edge case.&lt;/p&gt;

&lt;p&gt;How would I use this? The following code shows feeding this into a CreateBuilderWriter that is passed to XamlServices.Save()&lt;/p&gt;

&lt;pre class="csharpcode"&gt;StringBuilder sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();
XamlSchemaContext xsc = &lt;span class="kwrd"&gt;new&lt;/span&gt; XamlSchemaContext();
var bw = ActivityXamlServices.CreateBuilderWriter(
    &lt;span class="kwrd"&gt;new&lt;/span&gt; IgnorableXamlXmlWriter(&lt;span class="kwrd"&gt;new&lt;/span&gt; StringWriter(sb), xsc));

XamlServices.Save(bw,
                  wd.Context.Services.GetService&amp;lt;ModelTreeManager&amp;gt;().Root.GetCurrentValue());&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9935376" 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/xaml/default.aspx">xaml</category></item><item><title>AttachedProperty Part 2, Putting it Together</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/07/attachedproperty-part-2-putting-it-together.aspx</link><pubDate>Mon, 07 Dec 2009 05:19:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9933272</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9933272.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9933272</wfw:commentRss><description>&lt;p&gt;On my last &lt;a href="http://bit.ly/6z2THv"&gt;post&lt;/a&gt;&lt;a href="http://blogs.msdn.com/mwinkle/archive/2009/12/06/wf4-design-time-attachedpropertiesservice-and-attached-properties.aspx"&gt;&lt;/a&gt;, Jason jumped right to the punchline in his comment &lt;a href="http://bit.ly/6z2THv"&gt;here&lt;/a&gt;&lt;a href="http://blogs.msdn.com/mwinkle/archive/2009/12/06/wf4-design-time-attachedpropertiesservice-and-attached-properties.aspx#9933257"&gt;&lt;/a&gt;. He asks “if there is an easy way to have the properties value serialized out to the xaml.” &lt;/p&gt;  &lt;p&gt;First, let’s look at what we need to do from the XAML side.&lt;/p&gt;  &lt;p&gt;First, create a helper type with a getter and setter for the property that you want to attach.&amp;#160; Here we’re going to attach comments:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Comment
{
    &lt;span class="kwrd"&gt;static&lt;/span&gt; AttachableMemberIdentifier CommentTextName = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachableMemberIdentifier(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Comment), &lt;span class="str"&gt;&amp;quot;CommentText&amp;quot;&lt;/span&gt;);

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; GetCommentText(&lt;span class="kwrd"&gt;object&lt;/span&gt; instance)
    {
        &lt;span class="kwrd"&gt;object&lt;/span&gt; viewState;
        AttachablePropertyServices.TryGetProperty(instance, CommentTextName, &lt;span class="kwrd"&gt;out&lt;/span&gt; viewState);
        &lt;span class="kwrd"&gt;return&lt;/span&gt; viewState;
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetCommentText(&lt;span class="kwrd"&gt;object&lt;/span&gt; instance, &lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;)
    {
        AttachablePropertyServices.SetProperty(instance, CommentTextName, &lt;span class="kwrd"&gt;value&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;Next, let’s use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.xaml.attachablememberidentifier(VS.100).aspx"&gt;AttachableMemberIdentifier&lt;/a&gt; and the &lt;a href="http://msdn.microsoft.com/en-us/library/system.xaml.attachablepropertyservices(VS.100).aspx"&gt;AttachablePropertyServices&lt;/a&gt; to do something interesting with this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;AttachableMemberIdentifier ami = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachableMemberIdentifier(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Comment), &lt;span class="str"&gt;&amp;quot;CommentText&amp;quot;&lt;/span&gt;);
Dog newDog = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dog { Age = 12, Name = &lt;span class="str"&gt;&amp;quot;Sherlock&amp;quot;&lt;/span&gt;, Noise = &lt;span class="str"&gt;&amp;quot;Hooowl&amp;quot;&lt;/span&gt; };
AttachablePropertyServices.SetProperty(newDog, ami, &lt;span class="str"&gt;&amp;quot;A very good dog&amp;quot;&lt;/span&gt;);
&lt;span class="kwrd"&gt;string&lt;/span&gt; s = XamlServices.Save(newDog);
Console.WriteLine(&lt;span class="str"&gt;&amp;quot;XAML&amp;quot;&lt;/span&gt;);
Console.WriteLine(s);
Dog aSecondNewDog = XamlServices.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; StringReader(s)) &lt;span class="kwrd"&gt;as&lt;/span&gt; Dog;
&lt;span class="kwrd"&gt;string&lt;/span&gt; outter;
AttachablePropertyServices.TryGetProperty(aSecondNewDog, ami, &lt;span class="kwrd"&gt;out&lt;/span&gt; outter);
Console.WriteLine(&lt;span class="str"&gt;&amp;quot;read out: {0}&amp;quot;&lt;/span&gt;, outter);&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;Let’s see the output from this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;XAML
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Dog&lt;/span&gt;
     &lt;span class="attr"&gt;Age&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;12&amp;quot;&lt;/span&gt;
     &lt;span class="attr"&gt;Comment&lt;/span&gt;.&lt;span class="attr"&gt;CommentText&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;A very good dog&amp;quot;&lt;/span&gt;
     &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Sherlock&amp;quot;&lt;/span&gt;
     &lt;span class="attr"&gt;Noise&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Hooowl&amp;quot;&lt;/span&gt; 
     &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:AttachedPropertiesBlogPosting;assembly=AttachedPropertiesBlogPosting&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
read out: A very good dog&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;You’ll note that the value is contained in the XAML under Comment.CommentText.&lt;/p&gt;

&lt;h1&gt;Pulling it all Together&lt;/h1&gt;

&lt;p&gt;Let’s take what we did in the last post and combine it with the above stuff in order to have an attached property that writes through and is stored inside the XAML.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; Comment = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;
{
    IsBrowsable = &lt;span class="kwrd"&gt;true&lt;/span&gt;,
    Name = &lt;span class="str"&gt;&amp;quot;Comment&amp;quot;&lt;/span&gt;,
    Getter = (mi =&amp;gt;
        { &lt;span class="kwrd"&gt;string&lt;/span&gt; temp;
          AttachablePropertyServices.TryGetProperty&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;(mi.GetCurrentValue(), ami, &lt;span class="kwrd"&gt;out&lt;/span&gt; temp);
          &lt;span class="kwrd"&gt;return&lt;/span&gt; temp;
        }),
    Setter = ( (mi,val) =&amp;gt; AttachablePropertyServices.SetProperty(mi.GetCurrentValue(), ami, val) )

};
aps.AddProperty(Comment);
dogMi.Properties[&lt;span class="str"&gt;&amp;quot;Comment&amp;quot;&lt;/span&gt;].SetValue(&lt;span class="str"&gt;&amp;quot;I think I like that dog&amp;quot;&lt;/span&gt;);
&lt;span class="kwrd"&gt;string&lt;/span&gt; xaml = XamlServices.Save(dogMi.GetCurrentValue());
Console.WriteLine(&lt;span class="str"&gt;&amp;quot;XAML&amp;quot;&lt;/span&gt;);
Console.WriteLine(xaml);&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;What are we doing here, well, we basically just use the Getter and Setter to write through to the underlying instance.&amp;#160; You’ll note that usually, we never want to go and use GetCurrentValue(), as any changes made there are not made via the ModelItem tree which means we might miss a change notification.&amp;#160; However, given that the only place where we can store the XAML attached property is on the instance itself, this gives us a good way to write through.&amp;#160; The XAML output below shows that this works as expected:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Dog&lt;/span&gt; 
   &lt;span class="attr"&gt;Age&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;
   &lt;span class="attr"&gt;Comment&lt;/span&gt;.&lt;span class="attr"&gt;CommentText&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;I think I like that dog&amp;quot;&lt;/span&gt;
   &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Sasha&amp;quot;&lt;/span&gt; 
   &lt;span class="attr"&gt;Noise&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Snort&amp;quot;&lt;/span&gt; 
   &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:AttachedPropertiesBlogPosting;assembly=AttachedPropertiesBlogPosting&amp;quot;&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;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9933272" 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/vs2010/default.aspx">vs2010</category></item><item><title>WF4 Design Time AttachedPropertiesService and Attached Properties</title><link>http://blogs.msdn.com/mwinkle/archive/2009/12/06/wf4-design-time-attachedpropertiesservice-and-attached-properties.aspx</link><pubDate>Sun, 06 Dec 2009 04:51:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9933077</guid><dc:creator>mwinkle</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9933077.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9933077</wfw:commentRss><description>&lt;p&gt;I’ve been meaning to throw together some thoughts on attached properties and how they can be used within the designer.&amp;#160; Basically, you can think about attached properties as injecting some additional “stuff” onto an instance that you can use elsewhere in your code. &lt;/p&gt;  &lt;h1&gt;Motivation&lt;/h1&gt;  &lt;p&gt;In the designer, we want to be able to have behavior and view tied to interesting aspects of the data.&amp;#160; For instance, we would like to have a view updated when an item becomes selected.&amp;#160; In WPF, we bind the style based on the “isSelectionProperty.”&amp;#160; Now, our data model doesn’t have any idea of selection, it’s something we’d like the view level to “inject” that idea on any model item so that a subsequent view could take advantage of.&amp;#160; You can kind of view Attached Properties as a nice syntactic sugar to not have to keep a bunch of lookup lists around.&amp;#160; As things like WPF bind to the object very well, and not so much a lookup list, this ends up being an interesting model.&lt;/p&gt;  &lt;p&gt;To be clear, you could write a number of value converters that take the item being bound, look up in a lookup list somewhere, and return the result that will be used.&amp;#160; The problem we found is that we were doing this in a bunch of places, and we really wanted to have clean binding statements inside our WPF XAML, rather than hiding a bunch of logic in the converters. &lt;/p&gt;  &lt;h1&gt;How Does it Work&lt;/h1&gt;  &lt;p&gt;First, some types.&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="548"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="200"&gt;Name&lt;/td&gt;        &lt;td valign="top" width="346"&gt;Description&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedpropertiesservice(VS.100).aspx"&gt;&lt;a href="http://bit.ly/6dvvwh"&gt;AttachedPropertiesService&lt;/a&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="346"&gt;Service in editing context for managing AttachedProperties&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedproperty(VS.100).aspx"&gt;&lt;a href="http://bit.ly/4MioTX"&gt;AttachedProperty&lt;/a&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="346"&gt;Base attached property type (abstract)&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="200"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee473952(VS.100).aspx"&gt;&lt;a href="http://bit.ly/4NYHil"&gt;AttachedProperty&amp;lt;T&amp;gt;&lt;/a&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="346"&gt;Strongly typed attached property with interesting getter/setter programmability&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;in diagram form:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4DesignTimeAttachedPropertiesServicean_124AC/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/WF4DesignTimeAttachedPropertiesServicean_124AC/image_thumb.png" width="712" height="376" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;One thing that might look a little funny to some folks who have used attached properties in other contexts (WF3, WPF, XAML), is the “&lt;a href="http://bit.ly/5DvhJs"&gt;IsBrowsable&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedproperty.isbrowsable(VS.100).aspx"&gt;&lt;/a&gt;” property.&amp;#160; The documentation is a little sparse right now, but what this will do is determine how discoverable the property is.&amp;#160; If this is set to true, the attached property will show up in the Properties collection of the ModelItem to which the AP is attached.&amp;#160; What this means is that it can show up in the Property grid, you can bind WPF statements directly to it, as if it were a real property of the object.&amp;#160; Attached properties by themselves have no actual storage representation, so these exist as design time only constructs. &lt;/p&gt;  &lt;h2&gt;Getter/ Setter? &lt;/h2&gt;  &lt;p&gt;One other thing that you see on the &lt;a href="http://msdn.microsoft.com/en-us/library/ee473952(VS.100).aspx"&gt;&lt;/a&gt;&lt;a href="http://bit.ly/4NYHil"&gt;AttachedProperty&amp;lt;T&amp;gt;&lt;/a&gt;&lt;/a&gt; is the &lt;a href="http://bit.ly/5woYQg"&gt;Getter&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee473895(VS.100).aspx"&gt;&lt;/a&gt; and &lt;a href="http://bit.ly/75yEyX"&gt;Setter&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee473838(VS.100).aspx"&gt;&lt;/a&gt; properties.&amp;#160; These are of type Func&amp;lt;ModelItem,T&amp;gt; and Action&amp;lt;ModelItem,T&amp;gt; respectively.&amp;#160; What these allow you to do is perform some type of computation whenever the get or set is called against the AttachedProperty.&amp;#160; Why is this interesting?&amp;#160; Well, let’s say that you’d like to have a computed value retrieved, such as “IsPrimarySelection” checking with the Selection context item to see if an item is selected.&amp;#160; Or, customizing the setter to either store the value somewhere more durable, or updating a few different values.&amp;#160; The other thing that happens is that since all of these updates go through the ModelItem tree, any changes will be propagated to other listeners throughout the designer. &lt;/p&gt;  &lt;h1&gt;Looking at Some Code&lt;/h1&gt;  &lt;p&gt;Here is a very small console based app that shows how you can program against the attached properties.&amp;#160; An interesting exercise for the reader would be to take this data structure, put it in a WPF app and experiment with some of the data binding. &lt;/p&gt;  &lt;p&gt;First, two types:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Dog
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Noise { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Age { get; set; }
   
}

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Cat
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Noise { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Age { get; set; }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Ignore no common base type, that actually makes this a little more interesting, as we will see. &lt;/p&gt;

&lt;p&gt;Now, let’s write some code.&amp;#160; First, let’s initialize and &lt;a href="http://bit.ly/81kTQz"&gt;EditingContext&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.editingcontext(VS.100).aspx"&gt;&lt;/a&gt; and &lt;a href="http://bit.ly/5mJyPi"&gt;ModelTreeManager&lt;/a&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;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;   2:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            EditingContext ec = &lt;span class="kwrd"&gt;new&lt;/span&gt; EditingContext();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            ModelTreeManager mtm = &lt;span class="kwrd"&gt;new&lt;/span&gt; ModelTreeManager(ec);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            mtm.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { &lt;span class="kwrd"&gt;new&lt;/span&gt; Dog { Name = &lt;span class="str"&gt;&amp;quot;Sasha&amp;quot;&lt;/span&gt;, Noise = &lt;span class="str"&gt;&amp;quot;Snort&amp;quot;&lt;/span&gt;, Age = 5 },&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Cat { Name=&lt;span class="str"&gt;&amp;quot;higgs&amp;quot;&lt;/span&gt;, Noise=&lt;span class="str"&gt;&amp;quot;boom&amp;quot;&lt;/span&gt;, Age=1 } });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            dynamic root = mtm.Root;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            dynamic dog = root[0];&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            dynamic cat = root[1];&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            ModelItem dogMi = root[0] &lt;span class="kwrd"&gt;as&lt;/span&gt; ModelItem;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            ModelItem catMi = root[1] &lt;span class="kwrd"&gt;as&lt;/span&gt; ModelItem;&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;&lt;strong&gt;Note, lines 7-9 will not work in Beta2 (preview of coming attractions).&amp;#160; To get lines 10-11 working in beta2, cast root to ModelItemCollection and then use the indexers to extract the values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s build an attached property, and we will assign it only to type “dog”&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// Add an attached Property&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt; ap = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    IsBrowsable = &lt;span class="kwrd"&gt;true&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    Name = &lt;span class="str"&gt;&amp;quot;IsAnInterestingDog&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    Getter = (mi =&amp;gt; mi.Properties[&lt;span class="str"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;].ComputedValue.ToString() == &lt;span class="str"&gt;&amp;quot;Sasha&amp;quot;&lt;/span&gt;),&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    OwnerType = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Dog)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;ec.Services.Publish&amp;lt;AttachedPropertiesService&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedPropertiesService());&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;AttachedPropertiesService aps = ec.Services.GetService&amp;lt;AttachedPropertiesService&amp;gt;();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;aps.AddProperty(ap);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on dog (note new property)----&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;dogMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));&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;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on cat (note  no new property) ----&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;catMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Let’s break down what happened here.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Line2-8, create an AttachedProperty&amp;lt;bool&amp;gt;&lt;/li&gt;

  &lt;ul&gt;
    &lt;li&gt;We set &lt;a href="http://bit.ly/5DvhJs"&gt;IsBrowsable&lt;/a&gt; to true, we want to see it in the output&lt;/li&gt;

    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedproperty.name(VS.100).aspx"&gt;&lt;a href="http://bit.ly/5a2cJS"&gt;Name&lt;/a&gt;&lt;/a&gt;, that’s what it will be projected as&lt;/li&gt;

    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedproperty.ownertype(VS.100).aspx"&gt;&lt;a href="http://bit.ly/5GiqA1"&gt;OwnerType&lt;/a&gt;&lt;/a&gt;, we only want this to apply to Dog’s, not Cat’s or Objects or whatever.&lt;/li&gt;

    &lt;li&gt;Finally, &lt;a href="http://bit.ly/5woYQg"&gt;Getter&lt;/a&gt;, and look what we do here, we operate on the model item to do some computation and return a bool (in this case, we look to see if the name property equals “Sasha”&lt;/li&gt;
  &lt;/ul&gt;

  &lt;li&gt;Line 9-11 create an &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedpropertiesservice(VS.100).aspx"&gt;&lt;/a&gt;&lt;a href="http://bit.ly/6dvvwh"&gt;AttachedPropertiesService&lt;/a&gt;&lt;/a&gt; and add it to the editing context.&lt;/li&gt;

  &lt;li&gt;Lines 13-17 output the properties, and let’s see what that looks like:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;---- Enumerate properties on dog (note new property)----&lt;/pre&gt;

  &lt;pre&gt; Property : Name&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : Noise&lt;/pre&gt;

  &lt;pre&gt; Property : Age&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : IsAnInterestingDog&lt;/pre&gt;

  &lt;pre&gt;---- Enumerate properties on cat (note  no new property) ----&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : Name&lt;/pre&gt;

  &lt;pre&gt; Property : Noise&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : Age&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;Ok, so that’s interesting, we’ve injected a new property, only on the dog type.&amp;#160; If I got dogMI.Properties[“IsAnInterestingDog”], I would have a value that I could manipulate (albeit returned via the getter).&lt;/p&gt;

&lt;p&gt;Let’s try something a little different:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt; isYoungAnimal = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt;&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;    IsBrowsable = &lt;span class="kwrd"&gt;false&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    Name = &lt;span class="str"&gt;&amp;quot;IsYoungAnimal&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    Getter = (mi =&amp;gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;.Parse(mi.Properties[&lt;span class="str"&gt;&amp;quot;Age&amp;quot;&lt;/span&gt;].ComputedValue.ToString()) &amp;lt; 2)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;};&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;aps.AddProperty(isYoungAnimal);&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="rem"&gt;// expect to not see isYoungAnimal show up&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on dog  (note isYoungAnimal doesn't appear )----&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;dogMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on cat (note isYoungAnimal doesn't appear )----&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;catMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));&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;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- get attached property via GetValue ----&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;getting non browsable attached property on dog {0}&amp;quot;&lt;/span&gt;, isYoungAnimal.GetValue(dogMi));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;getting non browsable attached property on cat {0}&amp;quot;&lt;/span&gt;, isYoungAnimal.GetValue(catMi));&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Let’s break this down:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Lines 1-6 create a new attached property&lt;/li&gt;

  &lt;ul&gt;
    &lt;li&gt;IsBrowsable is false&lt;/li&gt;

    &lt;li&gt;No OwnerType being set&lt;/li&gt;

    &lt;li&gt;The Getter does some computation to return true or false&lt;/li&gt;
  &lt;/ul&gt;

  &lt;li&gt;Lines 10-14 write out the properties (as above)&lt;/li&gt;

  &lt;li&gt;Lines 17-18 extract the value with &lt;em&gt;&lt;a href="http://bit.ly/67pRXJ"&gt;AttachedPropertyInstance.GetValue(ModelItem)&lt;/a&gt;&lt;/em&gt;&lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.model.attachedproperty.getvalue(VS.100).aspx"&gt;&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s see the output there:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;--&lt;span class="rem"&gt;-- Enumerate properties on dog  (note isYoungAnimal doesn't appear )----&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt; Property : Name&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : Noise&lt;/pre&gt;

  &lt;pre&gt; Property : Age&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : IsAnInterestingDog&lt;/pre&gt;

  &lt;pre&gt;--&lt;span class="rem"&gt;-- Enumerate properties on cat (note isYoungAnimal doesn't appear )----&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : Name&lt;/pre&gt;

  &lt;pre&gt; Property : Noise&lt;/pre&gt;

  &lt;pre class="alt"&gt; Property : Age&lt;/pre&gt;

  &lt;pre&gt;--&lt;span class="rem"&gt;-- get attached property via GetValue ----&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;getting non browsable attached property &lt;span class="kwrd"&gt;on&lt;/span&gt; dog &lt;span class="kwrd"&gt;False&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;getting non browsable attached property &lt;span class="kwrd"&gt;on&lt;/span&gt; cat True&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;As we can see, we’ve now injected this behavior, and we can extract the value.&amp;#160; &lt;/p&gt;

&lt;p&gt;Let’s get a little more advanced and do something with the setter.&amp;#160; Here, if isYoungAnimal is set to true, we will change the age (it’s a bit contrived, but shows the dataflow on simple objects, we’ll see in a minute a more interesting case).&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// now, let's do something clever with the setter. &lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- let's use the setter to have some side effect ----&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;isYoungAnimal.Setter = ((mi, val) =&amp;gt; { &lt;span class="kwrd"&gt;if&lt;/span&gt; (val) { mi.Properties[&lt;span class="str"&gt;&amp;quot;Age&amp;quot;&lt;/span&gt;].SetValue(10); } });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;isYoungAnimal.SetValue(cat, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;cat's age now {0}&amp;quot;&lt;/span&gt;, cat.Age);&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;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;&lt;/p&gt;

  &lt;p&gt;Pay attention to what the Setter does now.&amp;#160; We create the method through which subsequent SetValue’s will be pushed.&amp;#160; Here’s that output:&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;--&lt;span class="rem"&gt;-- let's use the setter to have some side effect ----&lt;/span&gt;
cat's age now 10&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;Finally, let’s show an example of how this can really function as some nice sugar to eliminate the need for a lot of value converters in WPF by using this capability as a way to store the relationship somewhere (rather than just using at a nice proxy to change a value):&lt;/p&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// now, let's have a browesable one with a setter.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="rem"&gt;// this plus dynamics are a mini &amp;quot;macro language&amp;quot; against the model items&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;List&amp;lt;Object&amp;gt; FavoriteAnimals = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;();&lt;/pre&gt;

    &lt;pre&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="rem"&gt;// we maintain state in FavoriteAnimals, and use the getter/setter func&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="rem"&gt;// in order to query or edit that collection.  Thus changes to an &amp;quot;instance&amp;quot;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="rem"&gt;// are tracked elsewhere.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt; isFavoriteAnimal = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&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&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    IsBrowsable = &lt;span class="kwrd"&gt;false&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    Name = &lt;span class="str"&gt;&amp;quot;IsFavoriteAnimal&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    Getter = (mi =&amp;gt; FavoriteAnimals.Contains(mi)),&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    Setter = ((mi, val) =&amp;gt; &lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        {&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (val)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;                FavoriteAnimals.Add(mi);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;            &lt;span class="kwrd"&gt;else&lt;/span&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;                FavoriteAnimals.Remove(mi);&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;        })&lt;/pre&gt;

    &lt;pre&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;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;aps.AddProperty(isFavoriteAnimal);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;dog.IsFavoriteAnimal = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;&lt;span class="rem"&gt;// remove that cat that isn't there&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;cat.IsFavoriteAnimal = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;cat.IsFavoriteAnimal = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;cat.IsFavoriteAnimal = &lt;span class="kwrd"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&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;Who are my favorite animal?&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;FavoriteAnimals.ForEach(o =&amp;gt; Console.WriteLine((o &lt;span class="kwrd"&gt;as&lt;/span&gt; ModelItem).Properties[&lt;span class="str"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;].ComputedValue.ToString()));&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;Little bit of code, let’s break it down one last time:&lt;/p&gt;
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Line 14 – Create a setter that acts upon the FavoriteAnimals collection to either add or remove the element&lt;/li&gt;

  &lt;li&gt;Line 28-32 – do a few different sets on this attached property&lt;/li&gt;

  &lt;ul&gt;
    &lt;li&gt;NOTE: you can’t do that in beta2 as the dynamic support hasn’t been turned on.&amp;#160; Rather you would have to do isFavoriteAnimal.SetValue(dogMi, true).&lt;/li&gt;
  &lt;/ul&gt;

  &lt;li&gt;Line 35 then prints the output to the console, and as expected we only see the dog there:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;-- Who are my favorite animals?&lt;/span&gt;
Sasha&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;I will attach the whole code file at the bottom of this post, but this shows you how you can use the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Attached properties to create “computed values” on top of existing types&lt;/li&gt;

  &lt;li&gt;Attached properties to inject a new (and discoverable) property entry on top of the designer data model (in the form of a new property)&lt;/li&gt;

  &lt;li&gt;Using the Setter capability to both propagate real changes to the type, providing a nice way to give a cleaner interface, as well as use it as a mechanism to store data about the object outside of the object, but in a way that gives me access to it such that it seems like the object.&amp;#160; &lt;/li&gt;

  &lt;ul&gt;
    &lt;li&gt;This is some really nice syntactic sugar that we sprinkle on top of things&lt;/li&gt;
  &lt;/ul&gt;
&lt;/ul&gt;

&lt;h1&gt;What do I do now?&lt;/h1&gt;

&lt;p&gt;Hopefully this post gave you some ideas about how the attached property mechanisms work within the WF4 designer.&amp;#160; These give you a nice way to complement the data model and create nice bindable targets that your WPF Views can layer right on top of. &lt;/p&gt;

&lt;p&gt;A few ideas for these things:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Use the Setters to clean up a “messy” activity API into a single property type that you then build a custom editor for in the property grid.&amp;#160; &lt;/li&gt;

  &lt;li&gt;Use the Getters (and the integration into the ModelProperty collection) in order to create computational properties that are used for displaying interesting information on the designer surface.&lt;/li&gt;

  &lt;li&gt;Figure out how to bridge the gap to take advantage of the XAML attached property storage mechanism, especially if you author runtime types that look for attached properties at runtime.&amp;#160; &lt;/li&gt;

  &lt;li&gt;Use these, with a combination of custom activity designers to extract and display interesting runtime data from a tracking store&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h1&gt;Full Code Posting&lt;/h1&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Presentation;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Presentation.Model;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; AttachedPropertiesBlogPosting
{
    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program
    {
        &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)
        {
            EditingContext ec = &lt;span class="kwrd"&gt;new&lt;/span&gt; EditingContext();
            ModelTreeManager mtm = &lt;span class="kwrd"&gt;new&lt;/span&gt; ModelTreeManager(ec);
            mtm.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt;[] { &lt;span class="kwrd"&gt;new&lt;/span&gt; Dog { Name = &lt;span class="str"&gt;&amp;quot;Sasha&amp;quot;&lt;/span&gt;, Noise = &lt;span class="str"&gt;&amp;quot;Snort&amp;quot;&lt;/span&gt;, Age = 5 },
                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Cat { Name=&lt;span class="str"&gt;&amp;quot;higgs&amp;quot;&lt;/span&gt;, Noise=&lt;span class="str"&gt;&amp;quot;boom&amp;quot;&lt;/span&gt;, Age=1 } });
            dynamic root = mtm.Root;
            dynamic dog = root[0];
            dynamic cat = root[1];
            ModelItem dogMi = root[0] &lt;span class="kwrd"&gt;as&lt;/span&gt; ModelItem;
            ModelItem catMi = root[1] &lt;span class="kwrd"&gt;as&lt;/span&gt; ModelItem;
          
            &lt;span class="rem"&gt;// Add an attached Property&lt;/span&gt;
            AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt; ap = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt;
            {
                IsBrowsable = &lt;span class="kwrd"&gt;true&lt;/span&gt;,
                Name = &lt;span class="str"&gt;&amp;quot;IsAnInterestingDog&amp;quot;&lt;/span&gt;,
                Getter = (mi =&amp;gt; mi.Properties[&lt;span class="str"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;].ComputedValue.ToString() == &lt;span class="str"&gt;&amp;quot;Sasha&amp;quot;&lt;/span&gt;),
                OwnerType = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Dog)
            };
            ec.Services.Publish&amp;lt;AttachedPropertiesService&amp;gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedPropertiesService());
            AttachedPropertiesService aps = ec.Services.GetService&amp;lt;AttachedPropertiesService&amp;gt;();
            aps.AddProperty(ap);

            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on dog (note new property)----&amp;quot;&lt;/span&gt;);
            dogMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));

            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on cat (note  no new property) ----&amp;quot;&lt;/span&gt;);
            catMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));


            
            AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt; isYoungAnimal = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt;
            {
                IsBrowsable = &lt;span class="kwrd"&gt;false&lt;/span&gt;,
                Name = &lt;span class="str"&gt;&amp;quot;IsYoungAnimal&amp;quot;&lt;/span&gt;,
                Getter = (mi =&amp;gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;.Parse(mi.Properties[&lt;span class="str"&gt;&amp;quot;Age&amp;quot;&lt;/span&gt;].ComputedValue.ToString()) &amp;lt; 2)
            };

            aps.AddProperty(isYoungAnimal);

            &lt;span class="rem"&gt;// expect to not see isYoungAnimal show up&lt;/span&gt;
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on dog  (note isYoungAnimal doesn't appear )----&amp;quot;&lt;/span&gt;);
            dogMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- Enumerate properties on cat (note isYoungAnimal doesn't appear )----&amp;quot;&lt;/span&gt;);
            catMi.Properties.ToList().ForEach(mp =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot; Property : {0}&amp;quot;&lt;/span&gt;, mp.Name));

            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- get attached property via GetValue ----&amp;quot;&lt;/span&gt;);
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;getting non browsable attached property on dog {0}&amp;quot;&lt;/span&gt;, isYoungAnimal.GetValue(dogMi));
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;getting non browsable attached property on cat {0}&amp;quot;&lt;/span&gt;, isYoungAnimal.GetValue(catMi));
            
            
            &lt;span class="rem"&gt;// now, let's do something clever with the setter. &lt;/span&gt;
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;---- let's use the setter to have some side effect ----&amp;quot;&lt;/span&gt;);
            isYoungAnimal.Setter = ((mi, val) =&amp;gt; { &lt;span class="kwrd"&gt;if&lt;/span&gt; (val) { mi.Properties[&lt;span class="str"&gt;&amp;quot;Age&amp;quot;&lt;/span&gt;].SetValue(10); } });
            isYoungAnimal.SetValue(cat, &lt;span class="kwrd"&gt;true&lt;/span&gt;);
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;cat's age now {0}&amp;quot;&lt;/span&gt;, cat.Age);

            &lt;span class="rem"&gt;// now, let's have a browesable one with a setter.&lt;/span&gt;
            &lt;span class="rem"&gt;// this plus dynamics are a mini &amp;quot;macro language&amp;quot; against the model items&lt;/span&gt;

            List&amp;lt;Object&amp;gt; FavoriteAnimals = &lt;span class="kwrd"&gt;new&lt;/span&gt; List&amp;lt;&lt;span class="kwrd"&gt;object&lt;/span&gt;&amp;gt;();

            &lt;span class="rem"&gt;// we maintain state in FavoriteAnimals, and use the getter/setter func&lt;/span&gt;
            &lt;span class="rem"&gt;// in order to query or edit that collection.  Thus changes to an &amp;quot;instance&amp;quot;&lt;/span&gt;
            &lt;span class="rem"&gt;// are tracked elsewhere.&lt;/span&gt;
            AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt; isFavoriteAnimal = &lt;span class="kwrd"&gt;new&lt;/span&gt; AttachedProperty&amp;lt;&lt;span class="kwrd"&gt;bool&lt;/span&gt;&amp;gt;
            {
                IsBrowsable = &lt;span class="kwrd"&gt;false&lt;/span&gt;,
                Name = &lt;span class="str"&gt;&amp;quot;IsFavoriteAnimal&amp;quot;&lt;/span&gt;,
                Getter = (mi =&amp;gt; FavoriteAnimals.Contains(mi)),
                Setter = ((mi, val) =&amp;gt; 
                    {
                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (val)
                            FavoriteAnimals.Add(mi);
                        &lt;span class="kwrd"&gt;else&lt;/span&gt;
                        {
                            FavoriteAnimals.Remove(mi);
                        }
                    })
            };
            aps.AddProperty(isFavoriteAnimal);
            dog.IsFavoriteAnimal = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            &lt;span class="rem"&gt;// remove that cat that isn't there&lt;/span&gt;
            cat.IsFavoriteAnimal = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
            cat.IsFavoriteAnimal = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            cat.IsFavoriteAnimal = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Who are my favorite animals?&amp;quot;&lt;/span&gt;);
            FavoriteAnimals.ForEach(o =&amp;gt; Console.WriteLine((o &lt;span class="kwrd"&gt;as&lt;/span&gt; ModelItem).Properties[&lt;span class="str"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;].ComputedValue.ToString()));
            Console.ReadLine();
        }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Dog
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Noise { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Age { get; set; }
    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Cat
    {
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Noise { get; set; }
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Age { get; set; }
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9933077" 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/vs2010/default.aspx">vs2010</category></item><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>WF4, WCF and AppFabric Sessions @ PDC09</title><link>http://blogs.msdn.com/mwinkle/archive/2009/11/23/wf4-wcf-and-appfabric-pdc09.aspx</link><pubDate>Mon, 23 Nov 2009 23:16:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927614</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9927614.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9927614</wfw:commentRss><description>&lt;p&gt;I’m taking this week off to catch up on everything I haven’t done the last two months and to celebrate the &lt;a href="http://en.wikipedia.org/wiki/Thanksgiving"&gt;Thanksgiving holiday&lt;/a&gt; here in the US. &lt;/p&gt;  &lt;p&gt;PDC was a blast!&amp;#160; It was incredibly awesome to meet so many folks interested in WF and talking with others about how they are using (or plan to use) WF4.&amp;#160; I’ll be following up with a more detailed post on my talk, including demos and code, but I wanted to give a summary of the talks that came from my team at this PDC.&amp;#160; Below is the diagram that breaks down some of the “capabilities” of AppFabric and I have color coded them for the various talks that we gave.&amp;#160; All of the PDC Sessions are available online &lt;a href="http://microsoftpdc.com/Videos"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4WCFandAppFabricPDC09_D6DC/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/WF4WCFandAppFabricPDC09_D6DC/image_thumb.png" width="592" height="309" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;WF Talks&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT17"&gt;Spice Up Your Applications with Windows Workflow Foundation 4&lt;/a&gt; – Matt Winkler&lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/P09-22"&gt;Windows Workflow Foundation 4 from the Inside Out&lt;/a&gt; – Bob Schmidt&lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;WCF Talks&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT13"&gt;What’s New for Windows Communication Foundation 4&lt;/a&gt; – Ed Pinto&lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT55"&gt;Developing REST Applications with the .NET Framework&lt;/a&gt; – Henrik Nielsen &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;AppFabric Talks&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT25"&gt;Microsoft Application Server Technologies: Present and Future&lt;/a&gt; – Anil Nori &lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/SVR15"&gt;Microsoft BizTalk Server Futures and Roadmap&lt;/a&gt; –&amp;#160; Balasubramanian Sriram &lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT14"&gt;Workflow Services and Windows Server AppFabric&lt;/a&gt; – Mark Fussell&lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT27"&gt;Application Server Extensibility with Microsoft .NET 4 and Windows Server AppFabric&lt;/a&gt; – Nicholas Allen&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There’s a ton of great content up at the PDC site, plenty to sit back and enjoy!&amp;#160; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927614" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/pdc09/default.aspx">pdc09</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/AppFabric/default.aspx">AppFabric</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>WF4 Designer Bloggers</title><link>http://blogs.msdn.com/mwinkle/archive/2009/10/28/wf4-designer-bloggers.aspx</link><pubDate>Wed, 28 Oct 2009 17:29:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9914205</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9914205.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9914205</wfw:commentRss><description>&lt;p&gt;I wanted to put a quick note up as the team is starting to blog a little more frequently and putting some interesting content out there.&amp;#160; A few places to check out to hear from the folks on the team&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint"&gt;Endpoint&lt;/a&gt; – This is the general WF team blog, and has had some good posts &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint/archive/2009/10/26/going-to-pdc-want-to-meet-the-team.aspx"&gt;Going to PDC? Want to Meet the Team?&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint/archive/2009/10/21/client-profile-in-net-4.aspx"&gt;Client Profile in .NET 4&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="http://blogs.msdn.com/endpoint/archive/2009/10/20/wf4-changes-between-beta-1-and-beta-2.aspx"&gt;WF4 Changes between Beta1 and Beta2&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/cathyk"&gt;Cathy Dumas&lt;/a&gt; – Cathy is the PM on my team focused on the expression editing experience and the designer UX&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://blogs.msdn.com/cathyk/archive/2009/10/27/vb-expression-example-manipulating-generic-lists.aspx"&gt;VB Expressions Example: Manipulating Generic Lists&lt;/a&gt; &lt;/li&gt;      &lt;li&gt;&lt;a href="VB for C# Developers"&gt;VB for C# developers&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/kushals"&gt;Kushal Shah&lt;/a&gt; – Kushal is the PM on my team for debugging and Visual Studio integration&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;a href="http://blogs.msdn.com/kushals/archive/2009/10/27/adding-activities-on-the-designer-programmatically.aspx"&gt;Adding Activities on the designer programmatically&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="http://blogs.msdn.com/kushals/archive/2009/10/26/adding-variables-expressions-and-bindings-programmatically.aspx"&gt;Adding Variables, Expressions and Bindings Programmatically&lt;/a&gt;&lt;/li&gt;      &lt;li&gt;&lt;a href="WF 4.0 Templates - Beta2"&gt;WF4 Templates – Beta 2&lt;/a&gt;&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;What blogs are you reading for WF4 content?&amp;#160; What kind of stuff would you like to hear more about?&amp;#160; Let us know!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914205" width="1" height="1"&gt;</description><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/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>Introduction to WF Designer Rehosting (Part 2)</title><link>http://blogs.msdn.com/mwinkle/archive/2009/06/17/introduction-to-wf-designer-rehosting-part-2.aspx</link><pubDate>Wed, 17 Jun 2009 20:18:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9769899</guid><dc:creator>mwinkle</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9769899.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9769899</wfw:commentRss><description>&lt;p&gt;&lt;em&gt;standard beta disclaimer.&amp;#160; This is written against the beta1 API’s.&amp;#160; If this is 2014, the bits will look different.&amp;#160; When the bits update, I will make sure to have a new post that updates these (or points to SDK samples that do)&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;In yesterday’s post, we went over the core components of the designer.&amp;#160; Let’s now take that and build that rehosts the designer, and then we’ll circle back around and talk about what we did and what comes next.&lt;/p&gt;  &lt;p&gt;Start VS, Create a new project, and select a WPF project&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb.png" width="553" height="398" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Inside the VS project add references to the System.Activities.* assemblies.&amp;#160; For now, that list looks like&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;System.Activities.dll&lt;/li&gt;    &lt;li&gt;System.Activities.Design.Base.dll&lt;/li&gt;    &lt;li&gt;System.Activities.Design.dll&lt;/li&gt;    &lt;li&gt;System.Activities.Core.Design.dll&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_1.png" width="355" height="292" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You might think the list of design assemblies is excessive.&amp;#160; We’ll be collapsing probably into two design assemblies, one with the designer infrastructure and one with the activity designers in subsequent milestones.&lt;/p&gt;  &lt;p&gt;Create some layout in the WPF window to hold the various designer elements.&amp;#160; I usually do a three column grid for toolbox, property grid and designer canvas.&lt;/p&gt;  &lt;p&gt;The XAML for this looks roughly like this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;BlogPostRehosting.Window1&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Window1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;664&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;831&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;3*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now that we’ve got the layout down, let’s get down to business.&amp;#160; First let’s just get an app that displays the workflow designer and then we will add some other interesting features. We wanted to make it easy to get a canvas onto your host application, and to program against it.&amp;#160; The key type that we use is &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner(VS.100).aspx"&gt;WorkflowDesigner&lt;/a&gt;, this encapsulates all of the functionality, and operating context, required.&amp;#160; Let’s take a quick look at the type definition &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td width="334"&gt;Name&lt;/td&gt;

      &lt;td width="365"&gt;Description&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.context(VS.100).aspx"&gt;Context&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Gets or sets an EditingContext object that is a collection of services shared between all elements contained in the designer and used to interact between the host and the designer. Services are published and requested through the EditingContext.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.contextmenu(VS.100).aspx"&gt;ContextMenu&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Gets the context menu for this designer.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.debugmanagerview(VS.100).aspx"&gt;DebugManagerView&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.debug.debuggerservice(VS.100).aspx"&gt;Provides a DebuggerServicethat is used for runtime debugging. &lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.propertygridfontandcolordata(VS.100).aspx"&gt;PropertyGridFontAndColorData&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Sets the property grid font and color data.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.propertyinspectorview(VS.100).aspx"&gt;PropertyInspectorView&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Returns a UI element that allows the user to view and edit properties of the workflow.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.text(VS.100).aspx"&gt;Text&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Gets or sets the XAML string representation of the workflow.&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td width="334"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.workflowdesigner.view(VS.100).aspx"&gt;View&lt;/a&gt;&lt;/td&gt;

      &lt;td width="365"&gt;Returns a UI element that allows the user to view and edit the workflow visually. &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The editing context is where we will spend more time in the future, for now the View is probably what’s most interesting, as this is the primary designer canvas.&amp;#160; There are also some useful methods to load and persist the workflow as well. &lt;/p&gt;

&lt;p&gt;Let’s start off real simple, and write some code that will display a basic sequence, and we’ll get more sophisticated as we go along.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Design;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Core.Design;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Activities.Statements;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; BlogPostRehosting&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="rem"&gt;/// Interaction logic for Window1.xaml&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Window1 : Window&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Window1()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            InitializeComponent();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            LoadWorkflowDesigner();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LoadWorkflowDesigner()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            WorkflowDesigner wd = &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowDesigner();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;            (&lt;span class="kwrd"&gt;new&lt;/span&gt; DesignerMetadata()).Register();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            wd.Load(&lt;span class="kwrd"&gt;new&lt;/span&gt; Sequence &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                            { &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;                                Activities = &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;                                {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Persist(), &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;                                    &lt;span class="kwrd"&gt;new&lt;/span&gt; WriteLine()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;                                }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;                            });&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;            Grid.SetColumn(wd.View, 1);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;            grid1.Children.Add(wd.View);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Let’s walk through this line by line:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Line 22, construct the workflow designer&lt;/li&gt;

  &lt;li&gt;Line 23, Call Register on the DesignerMetadata class.&amp;#160; Note that this associates all of the out of the box activities with their out of the box designers.&amp;#160; This is optional as a host may wish to provide custom editors for all or some of the out of box activities, or may not be using the out of box activities.&lt;/li&gt;

  &lt;li&gt;Line 24-31, Call Load, passing in an instance of an object graph to display.&amp;#160; This gives the host some flexibility, as this instance could come from XAML, a database, JSON, user input, etc.&amp;#160; We simply create a basic sequence with two activities&lt;/li&gt;

  &lt;li&gt;Line 32, set the column for the view&lt;/li&gt;

  &lt;li&gt;Line 33, add the view to the display&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This gives us the following application:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_2.png" width="466" height="389" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now, that was pretty simple, but we’re also missing some key things, namely, the property grid.&amp;#160; It’s important to note however that this has all of the functionality of the designer (the variables designer, the overview map, etc.&amp;#160; This will react just the same as if you were building the workflow in VS.&amp;#160; &lt;/p&gt;

&lt;p&gt;Let’s add the property grid by adding the following two lines:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Grid.SetColumn(wd.PropertyInspectorView, 2);
grid1.Children.Add(wd.PropertyInspectorView);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This will let us see the property grid (so things get a little more interesting).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_3.png" width="381" height="315" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;So, we’re able to display the workflow and interact with it, but we probably also want to have a constrained authoring experience (not just editing), so that comes in the form of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.design.toolboxcontrol(VS.100).aspx"&gt;ToolboxControl&lt;/a&gt;.&amp;#160; For the sake of this blog post, we’ll use this in XAML, but we certainly can code against it imperatively as well.&amp;#160; &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;BlogPostRehosting.Window1&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:sad&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System.Activities.Design;assembly=System.Activities.Design&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;xmlns:sys&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;clr-namespace:System;assembly=mscorlib&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Window1&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;664&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;831&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sys:String&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;AssemblyName&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sys:String&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;grid1&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;1*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;3*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;2*&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl.Categories&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxCategoryItemsCollection&lt;/span&gt; &lt;span class="attr"&gt;CategoryName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;Basic&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.Sequence&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.If&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.Parallel&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.WriteLine&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxItemWrapper&lt;/span&gt; &lt;span class="attr"&gt;AssemblyName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource AssemblyName}&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ToolName&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;System.Activities.Statements.Persist&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxCategoryItemsCollection&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl.Categories&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;sad:ToolboxControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Window&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;This lets me specify the items I want to allow a user to drop.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/IntroductiontoWFDesignerRehostingPart2_F7F5/image_thumb_4.png" width="627" height="522" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The thing that is interesting to point out here is that we’ve built a full featured, constrained editor (with things like copy paste, undo/redo, etc) with not too much code.&lt;/p&gt;

&lt;p&gt;Next time, we’ll get into to doing some more interesting bits as well to interact with the item being edited, serialize to XAML, and explore the editing context some more.&amp;#160; Let me know what you think!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9769899" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</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></item></channel></rss>