<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Felice Pollano Blog - ReHosting</title>
    <link>http://www.felicepollano.com/</link>
    <description>The official Fatica Labs Blog!</description>
    <language>en-us</language>
    <copyright>Felice Pollano</copyright>
    <lastBuildDate>Mon, 14 Mar 2011 20:16:50 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>felice@felicepollano.com</managingEditor>
    <webMaster>felice@felicepollano.com</webMaster>
    <item>
      <trackback:ping>http://www.felicepollano.com/Trackback.aspx?guid=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5</trackback:ping>
      <pingback:server>http://www.felicepollano.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.felicepollano.com/PermaLink.aspx?guid=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5</pingback:target>
      <dc:creator>Felice Pollano</dc:creator>
      <wfw:comment>http://www.felicepollano.com/CommentView.aspx?guid=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5</wfw:comment>
      <wfw:commentRss>http://www.felicepollano.com/SyndicationService.asmx/GetEntryCommentsRss?guid=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is the list of the posts related to Workflow4 Re-Hosting
</p>
        <table border="1" cellspacing="0" cellpadding="2" width="400">
          <tbody>
            <tr>
              <td valign="top" width="63">
                <a href="http://www.felicepollano.com/2011/03/05/ReHostingWF4InMarkup.aspx" target="_blank">Post
1</a>
              </td>
              <td valign="top" width="337">
First drop, showing we can host the designer view in pure markup.</td>
            </tr>
            <tr>
              <td valign="top" width="63">
                <a href="http://www.felicepollano.com/2011/03/05/ReHostingWF4AddingTheActivitiesBar.aspx" target="_blank">Post
2</a>
              </td>
              <td valign="top" width="337">
Adding the activities bar into the game.</td>
            </tr>
            <tr>
              <td valign="top" width="63">
                <a href="http://www.felicepollano.com/2011/03/06/ReHostingWF4GettingRidOfTheBlueGear.aspx" target="_blank">Post
3</a>
              </td>
              <td valign="top" width="337">
Removing the blue gear, and adding the proper activity image.</td>
            </tr>
            <tr>
              <td valign="top" width="63">
                <a href="http://www.felicepollano.com/2011/03/07/WF4ReHostingLetsShowThePropertyGrid.aspx" target="_blank">Post
4</a>
              </td>
              <td valign="top" width="337">
Showing the property editor grid.</td>
            </tr>
            <tr>
              <td valign="top" width="63">
                <a href="http://www.felicepollano.com/2011/03/14/WF4ReHostingCommandRouting.aspx" target="_blank">Post
5</a>
              </td>
              <td valign="top" width="337">
Default WorkflowView command routing.</td>
            </tr>
          </tbody>
        </table>
        <p>
 
</p>
        <p>
          <a href="http://wf4host.codeplex.com/" target="_blank">
            <font size="4">Sample Project
has a place on Codeplex</font>
          </a>
          <font size="4">.</font>
        </p>
        <p>
          <a href="http://wf4host.codeplex.com/" target="_blank">
            <img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" border="0" src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=wf4host&amp;DownloadId=217314" />
          </a>
        </p>
        <img width="0" height="0" src="http://www.felicepollano.com/aggbug.ashx?id=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5" />
      </body>
      <title>WF4 ReHosting: bind all together</title>
      <guid isPermaLink="false">http://www.felicepollano.com/PermaLink.aspx?guid=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5</guid>
      <link>http://www.felicepollano.com/2011/03/14/WF4ReHostingBindAllTogether.aspx</link>
      <pubDate>Mon, 14 Mar 2011 20:16:50 GMT</pubDate>
      <description>&lt;p&gt;
This is the list of the posts related to Workflow4 Re-Hosting
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="400"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="63"&gt;
&lt;a href="http://www.felicepollano.com/2011/03/05/ReHostingWF4InMarkup.aspx" target="_blank"&gt;Post
1&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="337"&gt;
First drop, showing we can host the designer view in pure markup.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="63"&gt;
&lt;a href="http://www.felicepollano.com/2011/03/05/ReHostingWF4AddingTheActivitiesBar.aspx" target="_blank"&gt;Post
2&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="337"&gt;
Adding the activities bar into the game.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="63"&gt;
&lt;a href="http://www.felicepollano.com/2011/03/06/ReHostingWF4GettingRidOfTheBlueGear.aspx" target="_blank"&gt;Post
3&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="337"&gt;
Removing the blue gear, and adding the proper activity image.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="63"&gt;
&lt;a href="http://www.felicepollano.com/2011/03/07/WF4ReHostingLetsShowThePropertyGrid.aspx" target="_blank"&gt;Post
4&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="337"&gt;
Showing the property editor grid.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="63"&gt;
&lt;a href="http://www.felicepollano.com/2011/03/14/WF4ReHostingCommandRouting.aspx" target="_blank"&gt;Post
5&lt;/a&gt;&lt;/td&gt;
&lt;td valign="top" width="337"&gt;
Default WorkflowView command routing.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://wf4host.codeplex.com/" target="_blank"&gt;&lt;font size="4"&gt;Sample Project
has a place on Codeplex&lt;/font&gt;&lt;/a&gt;&lt;font size="4"&gt;.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://wf4host.codeplex.com/" target="_blank"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" border="0" src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=wf4host&amp;amp;DownloadId=217314"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.felicepollano.com/aggbug.ashx?id=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5" /&gt;</description>
      <comments>http://www.felicepollano.com/CommentView.aspx?guid=db2e2ee1-abf5-4d42-a3e9-7eb7d10351c5</comments>
      <category>Programmin</category>
      <category>Recipes</category>
      <category>ReHosting</category>
      <category>WF4</category>
    </item>
    <item>
      <trackback:ping>http://www.felicepollano.com/Trackback.aspx?guid=300c866a-1c2d-4f85-914e-e1792f56eda5</trackback:ping>
      <pingback:server>http://www.felicepollano.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.felicepollano.com/PermaLink.aspx?guid=300c866a-1c2d-4f85-914e-e1792f56eda5</pingback:target>
      <dc:creator>Felice Pollano</dc:creator>
      <wfw:comment>http://www.felicepollano.com/CommentView.aspx?guid=300c866a-1c2d-4f85-914e-e1792f56eda5</wfw:comment>
      <wfw:commentRss>http://www.felicepollano.com/SyndicationService.asmx/GetEntryCommentsRss?guid=300c866a-1c2d-4f85-914e-e1792f56eda5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There is an entire suite of command defined by the designer view:
</p>
        <ul>
          <ul>
            <ul>
              <li>
DesignerView.CopyAsImageCommand;</li>
              <li>
DesignerView.CopyCommand;</li>
              <li>
DesignerView.CreateArgumentCommand;</li>
              <li>
DesignerView.CreateVariableCommand;</li>
              <li>
DesignerView.CreateWorkflowElementCommand;</li>
              <li>
DesignerView.CutCommand;</li>
              <li>
DesignerView.CycleThroughDesignerCommand;</li>
              <li>
DesignerView.DeleteBreakpointCommand;</li>
              <li>
DesignerView.DisableBreakpointCommand;</li>
              <li>
DesignerView.EnableBreakpointCommand;</li>
              <li>
DesignerView.ExpandAllCommand;</li>
              <li>
DesignerView.ExpandCommand;</li>
              <li>
DesignerView.ExpandInPlaceCommand;</li>
              <li>
DesignerView.FitToScreenCommand;</li>
              <li>
DesignerView.GoToParentCommand;</li>
              <li>
DesignerView.InsertBreakpointCommand;</li>
              <li>
DesignerView.PasteCommand;</li>
              <li>
DesignerView.RedoCommand;</li>
              <li>
DesignerView.ResetZoomCommand;</li>
              <li>
DesignerView.SaveAsImageCommand;</li>
              <li>
DesignerView.SelectAllCommand;</li>
              <li>
DesignerView.ToggleArgumentDesignerCommand;</li>
              <li>
DesignerView.ToggleImportsDesignerCommand;</li>
              <li>
DesignerView.ToggleMiniMapCommand;</li>
              <li>
DesignerView.ToggleSelectionCommand;</li>
              <li>
DesignerView.ToggleVariableDesignerCommand;</li>
              <li>
DesignerView.UndoCommand;</li>
              <li>
DesignerView.ZoomInCommand;</li>
              <li>
DesignerView.ZoomOutCommand;</li>
            </ul>
          </ul>
        </ul>
        <p>
But since the view is internal in the designer it is not automatic binding commands
form the UI to the underlying target. So our hosting solution propose an attached
property, to route the command to the view in a way suitable in pure markup too. The
property we create is called<strong> DesignerCommandTarget</strong>, and is used as
below:
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="lnum"> 1: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">Button</span>
            <span class="attr">Style</span>
            <span class="kwrd">="{StaticResource
toolButton}"</span>
            <span class="attr">ToolTip</span>
            <span class="kwrd">="Zoom In"</span>
            <span class="attr">Command</span>
            <span class="kwrd">="wfview:DesignerView.ZoomInCommand"</span>
          </pre>
          <pre>
            <span class="lnum"> 2: </span>
            <span class="attr">host:HostingHelper</span>.<span class="attr">DesignerCommandTarget</span><span class="kwrd">="{StaticResource
wfHost}"</span></pre>
          <pre class="alt">
            <span class="lnum"> 3: </span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre>
            <span class="lnum"> 4: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">Image</span>
            <span class="attr">Source</span>
            <span class="kwrd">="Assets/zoom_in.png"</span>
            <span class="kwrd">&gt;&lt;/</span>
            <span class="html">Image</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 5: </span>
            <span class="kwrd">&lt;/</span>
            <span class="html">Button</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre>
            <span class="lnum"> 6: </span>
          </pre>
        </div>
        <style type="text/css">.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; }
</style>
        <p>
 
</p>
        <p>
So we basically bind the command to the button by using Command, as usual, but we
set the <strong>DesignerCommandTarget</strong> to our hosting instance, that is defined
in the resource. In order to have the commands exposed by the designer in XAML, we
added the <strong>wfview</strong> namespace reference as underlined below:
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="lnum"> 1: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">Window</span>
            <span class="attr">x:Class</span>
            <span class="kwrd">="WF4Host.MainWindow"</span>
          </pre>
          <pre>
            <span class="lnum"> 2: </span>
            <span class="attr">xmlns</span>
            <span class="kwrd">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 3: </span>
            <span class="attr">xmlns:x</span>
            <span class="kwrd">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
          </pre>
          <pre>
            <span class="lnum"> 4: </span>
            <span class="attr">xmlns:toolbox</span>
            <span class="kwrd">="clr-namespace:System.Activities.Presentation.Toolbox;assembly=System.Activities.Presentation"</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 5: </span>
            <span class="attr">xmlns:host</span>
            <span class="kwrd">="clr-namespace:WF4Host"</span>
          </pre>
          <pre>
            <span class="lnum"> 6: </span>
            <span class="attr">xmlns:custom</span>
            <span class="kwrd">="clr-namespace:MyActivities;assembly=MyActivities"</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 7: </span>
            <span class="attr">xmlns:wf</span>
            <span class="kwrd">="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"</span>
          </pre>
          <pre>
            <span class="lnum"> 8: </span>
            <u>
              <strong>
                <span class="attr">xmlns:wfview</span>
                <span class="kwrd">="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"</span>
              </strong>
            </u>
          </pre>
          <pre class="alt">
            <span class="lnum"> 9: </span>
            <span class="attr">xmlns:activities</span>
            <span class="kwrd">="clr-namespace:System.Activities.Statements;assembly=System.Activities"</span>
          </pre>
          <pre>
            <span class="lnum"> 10: </span>
            <span class="attr">Title</span>
            <span class="kwrd">="MainWindow"</span>
            <span class="attr">Height</span>
            <span class="kwrd">="650"</span>
            <span class="attr">Width</span>
            <span class="kwrd">="825"</span>
          </pre>
          <pre class="alt">
            <span class="lnum"> 11: </span>
            <span class="attr">Icon</span>
            <span class="kwrd">="Assets/App.ico"</span>
          </pre>
          <pre>
            <span class="lnum"> 12: </span>
            <span class="attr">TextOptions</span>.<span class="attr">TextFormattingMode</span><span class="kwrd">="Display"</span></pre>
          <pre class="alt">
            <span class="lnum"> 13: </span>
          </pre>
          <pre>
            <span class="lnum"> 14: </span>
            <span class="kwrd">&gt;</span>
          </pre>
        </div>
        <style type="text/css">.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; }
</style>
        <p>
Command routing is very simple, and it is shown below:
</p>
        <p>
 
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="lnum"> 1: </span>
            <span class="kwrd">protected</span>
            <span class="kwrd">static</span>
            <span class="kwrd">void</span> OnCommandTargetChanged(DependencyObject
depo, DependencyPropertyChangedEventArgs depa)</pre>
          <pre>
            <span class="lnum"> 2: </span> {</pre>
          <pre class="alt">
            <span class="lnum"> 3: </span> var
src = depo <span class="kwrd">as</span> ICommandSource;</pre>
          <pre>
            <span class="lnum"> 4: </span>
            <span class="kwrd">if</span> (<span class="kwrd">null</span> !=
src &amp;&amp; depa.NewValue != <span class="kwrd">null</span> )</pre>
          <pre class="alt">
            <span class="lnum"> 5: </span> {</pre>
          <pre>
            <span class="lnum"> 6: </span> var
ctargetdescr = DependencyPropertyDescriptor.FromName(<span class="str">"CommandTarget"</span></pre>
          <pre class="alt">
            <span class="lnum"> 7: </span> ,
depo.GetType()</pre>
          <pre>
            <span class="lnum"> 8: </span> , depo.GetType()</pre>
          <pre class="alt">
            <span class="lnum"> 9: </span> ,<span class="kwrd">true</span>);</pre>
          <pre>
            <span class="lnum"> 10: </span> ctargetdescr.SetValue(depo</pre>
          <pre class="alt">
            <span class="lnum"> 11: </span>,
(depa.NewValue <span class="kwrd">as</span> HostingHelper).Designer.Context.Services.GetService&lt;DesignerView&gt;());</pre>
          <pre>
            <span class="lnum"> 12: </span> }</pre>
          <pre class="alt">
            <span class="lnum"> 13: </span> }</pre>
        </div>
        <style type="text/css">.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; }
</style>
        <p>
Every time we attach the property we check if the target is a <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.icommandsource.aspx" target="_blank">CommandSource</a>,
so basically the strategy works for any object implementing this interface. If this
pre condition is satisfied, we simply bind the WorkflowDesigner view as a <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.icommandsource.commandtarget.aspx" target="_blank">CommandTarget</a> for
that source. In this way commands from our UI behave as they are defined inside the
workflow, and we don’t need to write any code behind to custom wire them.
</p>
        <p>
Our example application now looks like this:
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.felicepollano.com/public/WindowsLiveWriter/WF4ReHostingcommandrouting_A4BA/image_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.felicepollano.com/public/WindowsLiveWriter/WF4ReHostingcommandrouting_A4BA/image_thumb.png" width="393" height="351" />
          </a>
        </p>
        <h5>Code for this post <a href="http://wf4host.codeplex.com/" target="_blank">is hosted
here</a>.
</h5>
        <img width="0" height="0" src="http://www.felicepollano.com/aggbug.ashx?id=300c866a-1c2d-4f85-914e-e1792f56eda5" />
      </body>
      <title>WF4 Re-Hosting: command routing</title>
      <guid isPermaLink="false">http://www.felicepollano.com/PermaLink.aspx?guid=300c866a-1c2d-4f85-914e-e1792f56eda5</guid>
      <link>http://www.felicepollano.com/2011/03/14/WF4ReHostingCommandRouting.aspx</link>
      <pubDate>Mon, 14 Mar 2011 11:13:09 GMT</pubDate>
      <description>&lt;p&gt;
There is an entire suite of command defined by the designer view:
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
DesignerView.CopyAsImageCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.CopyCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.CreateArgumentCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.CreateVariableCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.CreateWorkflowElementCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.CutCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.CycleThroughDesignerCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.DeleteBreakpointCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.DisableBreakpointCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.EnableBreakpointCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ExpandAllCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ExpandCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ExpandInPlaceCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.FitToScreenCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.GoToParentCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.InsertBreakpointCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.PasteCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.RedoCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ResetZoomCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.SaveAsImageCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.SelectAllCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ToggleArgumentDesignerCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ToggleImportsDesignerCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ToggleMiniMapCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ToggleSelectionCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ToggleVariableDesignerCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.UndoCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ZoomInCommand;&lt;/li&gt;
&lt;li&gt;
DesignerView.ZoomOutCommand;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;
But since the view is internal in the designer it is not automatic binding commands
form the UI to the underlying target. So our hosting solution propose an attached
property, to route the command to the view in a way suitable in pure markup too. The
property we create is called&lt;strong&gt; DesignerCommandTarget&lt;/strong&gt;, and is used as
below:
&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;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
toolButton}"&lt;/span&gt; &lt;span class="attr"&gt;ToolTip&lt;/span&gt;&lt;span class="kwrd"&gt;="Zoom In"&lt;/span&gt; &lt;span class="attr"&gt;Command&lt;/span&gt;&lt;span class="kwrd"&gt;="wfview:DesignerView.ZoomInCommand"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 2: &lt;/span&gt; &lt;span class="attr"&gt;host:HostingHelper&lt;/span&gt;.&lt;span class="attr"&gt;DesignerCommandTarget&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
wfHost}"&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;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Image&lt;/span&gt; &lt;span class="attr"&gt;Source&lt;/span&gt;&lt;span class="kwrd"&gt;="Assets/zoom_in.png"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Image&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&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;&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;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 6: &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;nbsp;
&lt;/p&gt;
&lt;p&gt;
So we basically bind the command to the button by using Command, as usual, but we
set the &lt;strong&gt;DesignerCommandTarget&lt;/strong&gt; to our hosting instance, that is defined
in the resource. In order to have the commands exposed by the designer in XAML, we
added the &lt;strong&gt;wfview&lt;/strong&gt; namespace reference as underlined below:
&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;&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;="WF4Host.MainWindow"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 2: &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;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 3: &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;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt; &lt;span class="attr"&gt;xmlns:toolbox&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System.Activities.Presentation.Toolbox;assembly=System.Activities.Presentation"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 5: &lt;/span&gt; &lt;span class="attr"&gt;xmlns:host&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:WF4Host"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 6: &lt;/span&gt; &lt;span class="attr"&gt;xmlns:custom&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:MyActivities;assembly=MyActivities"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 7: &lt;/span&gt; &lt;span class="attr"&gt;xmlns:wf&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 8: &lt;/span&gt; &lt;u&gt;&lt;strong&gt;&lt;span class="attr"&gt;xmlns:wfview&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation"&lt;/span&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 9: &lt;/span&gt; &lt;span class="attr"&gt;xmlns:activities&lt;/span&gt;&lt;span class="kwrd"&gt;="clr-namespace:System.Activities.Statements;assembly=System.Activities"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 10: &lt;/span&gt; &lt;span class="attr"&gt;Title&lt;/span&gt;&lt;span class="kwrd"&gt;="MainWindow"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="650"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="825"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 11: &lt;/span&gt; &lt;span class="attr"&gt;Icon&lt;/span&gt;&lt;span class="kwrd"&gt;="Assets/App.ico"&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 12: &lt;/span&gt; &lt;span class="attr"&gt;TextOptions&lt;/span&gt;.&lt;span class="attr"&gt;TextFormattingMode&lt;/span&gt;&lt;span class="kwrd"&gt;="Display"&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="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;
Command routing is very simple, and it is shown below:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&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;protected&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnCommandTargetChanged(DependencyObject
depo, DependencyPropertyChangedEventArgs depa)&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; var
src = depo &lt;span class="kwrd"&gt;as&lt;/span&gt; ICommandSource;&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;null&lt;/span&gt; !=
src &amp;amp;&amp;amp; depa.NewValue != &lt;span class="kwrd"&gt;null&lt;/span&gt; )&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; var
ctargetdescr = DependencyPropertyDescriptor.FromName(&lt;span class="str"&gt;"CommandTarget"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 7: &lt;/span&gt; ,
depo.GetType()&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 8: &lt;/span&gt; , depo.GetType()&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 9: &lt;/span&gt; ,&lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 10: &lt;/span&gt; ctargetdescr.SetValue(depo&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt; 11: &lt;/span&gt;,
(depa.NewValue &lt;span class="kwrd"&gt;as&lt;/span&gt; HostingHelper).Designer.Context.Services.GetService&amp;lt;DesignerView&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; }&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;
Every time we attach the property we check if the target is a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.input.icommandsource.aspx" target="_blank"&gt;CommandSource&lt;/a&gt;,
so basically the strategy works for any object implementing this interface. If this
pre condition is satisfied, we simply bind the WorkflowDesigner view as a &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.input.icommandsource.commandtarget.aspx" target="_blank"&gt;CommandTarget&lt;/a&gt; for
that source. In this way commands from our UI behave as they are defined inside the
workflow, and we don’t need to write any code behind to custom wire them.
&lt;/p&gt;
&lt;p&gt;
Our example application now looks like this:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.felicepollano.com/public/WindowsLiveWriter/WF4ReHostingcommandrouting_A4BA/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://www.felicepollano.com/public/WindowsLiveWriter/WF4ReHostingcommandrouting_A4BA/image_thumb.png" width="393" height="351"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;h5&gt;Code for this post &lt;a href="http://wf4host.codeplex.com/" target="_blank"&gt;is hosted
here&lt;/a&gt;.
&lt;/h5&gt;
&lt;img width="0" height="0" src="http://www.felicepollano.com/aggbug.ashx?id=300c866a-1c2d-4f85-914e-e1792f56eda5" /&gt;</description>
      <comments>http://www.felicepollano.com/CommentView.aspx?guid=300c866a-1c2d-4f85-914e-e1792f56eda5</comments>
      <category>Programmin</category>
      <category>Recipes</category>
      <category>ReHosting</category>
      <category>WF4</category>
    </item>
    <item>
      <trackback:ping>http://www.felicepollano.com/Trackback.aspx?guid=221c6854-b9aa-48fd-ab91-9535e2f6e649</trackback:ping>
      <pingback:server>http://www.felicepollano.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.felicepollano.com/PermaLink.aspx?guid=221c6854-b9aa-48fd-ab91-9535e2f6e649</pingback:target>
      <dc:creator>Felice Pollano</dc:creator>
      <wfw:comment>http://www.felicepollano.com/CommentView.aspx?guid=221c6854-b9aa-48fd-ab91-9535e2f6e649</wfw:comment>
      <wfw:commentRss>http://www.felicepollano.com/SyndicationService.asmx/GetEntryCommentsRss?guid=221c6854-b9aa-48fd-ab91-9535e2f6e649</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p align="justify">
Showing the property grid is achieved using  <a href="http://www.felicepollano.com/2011/03/05/ReHostingWF4InMarkup.aspx" target="_blank">the
same strategy we used to show the main editor</a>, since it is a View internally exposed
by the <a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.workflowdesigner.aspx" target="_blank">WorkflowDesigner</a>.
So we can decide where to put the property grid in XAML only in order to be blend
friendly. Let’s have a look at the XAML:
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="lnum"> 1: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">toolbox:ToolboxControl</span>
            <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="0"</span><span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="1"</span><span class="attr">host:ToolboxItemSource</span>.<span class="attr">CategorySource</span><span class="kwrd">="{StaticResource
GeneralTools}"</span><span class="kwrd">/&gt;</span></pre>
          <pre>
            <span class="lnum"> 2: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">GridSplitter</span>
            <span class="attr">ResizeDirection</span>
            <span class="kwrd">="Columns"</span>
            <span class="attr">Grid</span>.<span class="attr">RowSpan</span><span class="kwrd">="3"</span><span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="1"</span><span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="1"</span><span class="attr">Height</span><span class="kwrd">="Auto"</span><span class="attr">Width</span><span class="kwrd">="Auto"</span><span class="attr">HorizontalAlignment</span><span class="kwrd">="Stretch"</span><span class="attr">VerticalAlignment</span><span class="kwrd">="Stretch"</span><span class="kwrd">/&gt;</span></pre>
          <pre class="alt">
            <span class="lnum"> 3: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">host:MainViewPresenter</span>
            <span class="attr">HostingHelper</span>
            <span class="kwrd">="{StaticResource
wfHost}"</span>
            <span class="attr">Grid</span>.<span class="attr">RowSpan</span><span class="kwrd">="3"</span><span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="2"</span><span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="1"</span><span class="kwrd">/&gt;</span></pre>
          <pre>
            <span class="lnum"> 4: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">GridSplitter</span>
            <span class="attr">ResizeDirection</span>
            <span class="kwrd">="Rows"</span>
            <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="0"</span><span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="2"</span><span class="attr">Height</span><span class="kwrd">="Auto"</span><span class="attr">VerticalAlignment</span><span class="kwrd">="Stretch"</span><span class="attr">HorizontalAlignment</span><span class="kwrd">="Stretch"</span><span class="kwrd">/&gt;</span></pre>
          <pre class="alt">
            <span class="lnum"> 5: </span>
            <span class="kwrd">&lt;</span>
            <span class="html">host:PropertyViewPresenter</span>
            <span class="attr">HostingHelper</span>
            <span class="kwrd">="{StaticResource
wfHost}"</span>
            <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="0"</span><span class="attr">Grid</span>.<span class="attr">Row</span><span class="kwrd">="3"</span><span class="kwrd">/&gt;</span></pre>
        </div>
        <style type="text/css">.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; }
</style>
        <p>
Here we have all the graphical widget composing the designer as XAML tags. At line
5 we actually present the property editor. As a noise there is also some splitter
we add in order to have a better usable interface. Code for the presenter is quite
the same as the one we use to present the main view. So similar that could be refactor
in some base class, but it is not done at the moment. 
</p>
        <p>
What we have right now is this:
</p>
        <p>
          <a href="http://www.felicepollano.com/public/Windows-Live-Writer/WF4-Re-Hosting-lets-show-the-property-gr_12ED7/image_2.png">
            <img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.felicepollano.com/public/Windows-Live-Writer/WF4-Re-Hosting-lets-show-the-property-gr_12ED7/image_thumb.png" width="568" height="382" />
          </a>
        </p>
        <p>
A little problem appear to be the cursor over the splitter. <a href="http://connect.microsoft.com/VisualStudio/feedback/details/534173/rehosted-workflow-designer-stops-changing-resizing-mouse-cursor" target="_blank">For
some weird reason the WF controls seems to stole the mouse cursor management and there
is no way out to change it</a>. 
</p>
        <p>
A poor man workaround is to make the splitter turn to bold when the mouse hover on
it:
</p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">&lt;</span>
            <span class="html">Style</span>
            <span class="attr">TargetType</span>
            <span class="kwrd">="GridSplitter"</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre>
            <span class="kwrd">&lt;</span>
            <span class="html">Style.Triggers</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre class="alt">
            <span class="kwrd">&lt;</span>
            <span class="html">Trigger</span>
            <span class="attr">Property</span>
            <span class="kwrd">="IsMouseOver"</span>
            <span class="attr">Value</span>
            <span class="kwrd">="true"</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre>
            <span class="kwrd">&lt;</span>
            <span class="html">Setter</span>
            <span class="attr">Property</span>
            <span class="kwrd">="Background"</span>
            <span class="attr">Value</span>
            <span class="kwrd">="Black"</span>
            <span class="kwrd">/&gt;</span>
          </pre>
          <pre class="alt">
            <span class="kwrd">&lt;/</span>
            <span class="html">Trigger</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">&lt;/</span>
            <span class="html">Style.Triggers</span>
            <span class="kwrd">&gt;</span>
          </pre>
          <pre>
            <span class="kwrd">&lt;/</span>
            <span class="html">Style</span>
            <span class="kwrd">&gt;</span>
          </pre>
        </div>
        <style type="text/css">.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; }
</style>
        <p>
 
</p>
        <p>
As usual <a href="http://wf4host.codeplex.com/" target="_blank">the code so far can
be found here</a>. 
</p>
        <img width="0" height="0" src="http://www.felicepollano.com/aggbug.ashx?id=221c6854-b9aa-48fd-ab91-9535e2f6e649" />
      </body>
      <title>WF4 Re-Hosting: let’s show the property grid</title>
      <guid isPermaLink="false">http://www.felicepollano.com/PermaLink.aspx?guid=221c6854-b9aa-48fd-ab91-9535e2f6e649</guid>
      <link>http://www.felicepollano.com/2011/03/07/WF4ReHostingLetsShowThePropertyGrid.aspx</link>
      <pubDate>Mon, 07 Mar 2011 20:41:30 GMT</pubDate>
      <description>&lt;p align="justify"&gt;
Showing the property grid is achieved using&amp;nbsp; &lt;a href="http://www.felicepollano.com/2011/03/05/ReHostingWF4InMarkup.aspx" target="_blank"&gt;the
same strategy we used to show the main editor&lt;/a&gt;, since it is a View internally exposed
by the &lt;a href="http://msdn.microsoft.com/en-us/library/system.activities.presentation.workflowdesigner.aspx" target="_blank"&gt;WorkflowDesigner&lt;/a&gt;.
So we can decide where to put the property grid in XAML only in order to be blend
friendly. Let’s have a look at the XAML:
&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;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;toolbox:ToolboxControl&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;="0"&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;="1"&lt;/span&gt; &lt;span class="attr"&gt;host:ToolboxItemSource&lt;/span&gt;.&lt;span class="attr"&gt;CategorySource&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
GeneralTools}"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 2: &lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;GridSplitter&lt;/span&gt; &lt;span class="attr"&gt;ResizeDirection&lt;/span&gt;&lt;span class="kwrd"&gt;="Columns"&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;RowSpan&lt;/span&gt;&lt;span class="kwrd"&gt;="3"&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;="1"&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;="1"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&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;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;host:MainViewPresenter&lt;/span&gt; &lt;span class="attr"&gt;HostingHelper&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
wfHost}"&lt;/span&gt; &lt;span class="attr"&gt;Grid&lt;/span&gt;.&lt;span class="attr"&gt;RowSpan&lt;/span&gt;&lt;span class="kwrd"&gt;="3"&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;="2"&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;="1"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt; 4: &lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;GridSplitter&lt;/span&gt; &lt;span class="attr"&gt;ResizeDirection&lt;/span&gt;&lt;span class="kwrd"&gt;="Rows"&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;="0"&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;="2"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Stretch"&lt;/span&gt;&lt;span class="kwrd"&gt;/&amp;gt;&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;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;host:PropertyViewPresenter&lt;/span&gt; &lt;span class="attr"&gt;HostingHelper&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
wfHost}"&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;="0"&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;="3"&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;
Here we have all the graphical widget composing the designer as XAML tags. At line
5 we actually present the property editor. As a noise there is also some splitter
we add in order to have a better usable interface. Code for the presenter is quite
the same as the one we use to present the main view. So similar that could be refactor
in some base class, but it is not done at the moment. 
&lt;/p&gt;
&lt;p&gt;
What we have right now is this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.felicepollano.com/public/Windows-Live-Writer/WF4-Re-Hosting-lets-show-the-property-gr_12ED7/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.felicepollano.com/public/Windows-Live-Writer/WF4-Re-Hosting-lets-show-the-property-gr_12ED7/image_thumb.png" width="568" height="382"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
A little problem appear to be the cursor over the splitter. &lt;a href="http://connect.microsoft.com/VisualStudio/feedback/details/534173/rehosted-workflow-designer-stops-changing-resizing-mouse-cursor" target="_blank"&gt;For
some weird reason the WF controls seems to stole the mouse cursor management and there
is no way out to change it&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
A poor man workaround is to make the splitter turn to bold when the mouse hover on
it:
&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;Style&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="GridSplitter"&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;Style.Triggers&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;Trigger&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="IsMouseOver"&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="true"&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;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Background"&lt;/span&gt; &lt;span class="attr"&gt;Value&lt;/span&gt;&lt;span class="kwrd"&gt;="Black"&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;Trigger&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style.Triggers&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;Style&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;nbsp;
&lt;/p&gt;
&lt;p&gt;
As usual &lt;a href="http://wf4host.codeplex.com/" target="_blank"&gt;the code so far can
be found here&lt;/a&gt;. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.felicepollano.com/aggbug.ashx?id=221c6854-b9aa-48fd-ab91-9535e2f6e649" /&gt;</description>
      <comments>http://www.felicepollano.com/CommentView.aspx?guid=221c6854-b9aa-48fd-ab91-9535e2f6e649</comments>
      <category>Programmin</category>
      <category>Recipes</category>
      <category>ReHosting</category>
      <category>WF4</category>
    </item>
  </channel>
</rss>