<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Kushal Shah - Workflows</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/kushals/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/kushals/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:23:20 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>WF3 Design Time Performance - III</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/wf3-design-time-performance-iii</link>
      <pubDate>Fri, 09 Apr 2010 11:13:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/04/09/wf3-design-time-performance-iii/</guid>
      <description><![CDATA[By this time you are saying, I don't want tips/trouble shooting anymore. I have a large workflow and...]]></description>
      <content:encoded><![CDATA[<P>By this time you are saying, I don't want tips/trouble shooting anymore. I have a large workflow and I cant really re-factor it further. How can I improve the performance? </P>
<P>One of the customers actually told us that the way his system was designed, re-factoring might result into affecting runtime performance since he would need to be passing context across different State Machines. Hence, he would rather take the design time performance hit, than the runtime performance issues.</P>
<P>Well, we have heard these customers. Starting in VS 2010 RTM, the design time workflow performance has been improved drastically across the board. Please find some of the statistics we took recently comparing VS 2008 SP1 and VS 2010 for design time workflow performance. </P>
<P>Custom State Machine Workflow with ~10K lines of Code Besides and ~500 activities</P>
<TABLE border=1 cellSpacing=0 cellPadding=2 width=563>
<TBODY>
<TR>
<TD vAlign=top width=230><STRONG>Scenario</STRONG></TD>
<TD vAlign=top width=164><STRONG>VS 2008 SP1</STRONG></TD>
<TD vAlign=top width=167><STRONG>VS 2010</STRONG></TD></TR>
<TR>
<TD vAlign=top width=230>Cold Open Workflow Designer</TD>
<TD vAlign=top width=164>40</TD>
<TD vAlign=top width=167>21</TD></TR>
<TR>
<TD vAlign=top width=230>Warm Open Workflow Designer*</TD>
<TD vAlign=top width=164>31</TD>
<TD vAlign=top width=167>13</TD></TR>
<TR>
<TD vAlign=top width=230>Activity Bind Launch**</TD>
<TD vAlign=top width=165>153</TD>
<TD vAlign=top width=167>30</TD></TR></TBODY></TABLE>
<P>*: Warm scenario is one where you have opened the designer at least once and closed it. So the subsequent opening of the designer in the same VS instance is called a Warm open.</P>
<P>**: Note that the Activity Bind dialog numbers are also similar to what you will notice for Code Handler generation or the Type Browser dialog launch or the Rule Set editor launch. </P>
<P>The final question, you got is, I cant move to VS 2010 right now. Is there a QFE or patch we can apply to VS 2008 SP1? Again, I am really pleased to announce that the answer is a resounding YES. The QFE is now available to the customers <A href="https://support.microsoft.com/kb/980951/" mce_href="https://support.microsoft.com/kb/980951/">here</A> and <A href="https://support.microsoft.com/kb/980952/en-us" mce_href="https://support.microsoft.com/kb/980952/en-us">here</A>(apply them together for maximum benefits!). So go ahead, try the patches on VS 2008 SP1 or move to VS 2010 RTM&nbsp;and see for yourself the tremendous improvements the product team has delivered for WF3 Designers.</P>
<P>Hope this 3 part series helps you in improving the designer performance considerably. As always, ping me if you have any questions/concerns.</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>WF3 Design Time Performance - II</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/wf3-design-time-performance-ii</link>
      <pubDate>Wed, 07 Apr 2010 10:13:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/04/07/wf3-design-time-performance-ii/</guid>
      <description><![CDATA[Recently, we worked with one of the customers whose designer launch was painfully slow. The project...]]></description>
      <content:encoded><![CDATA[<P>Recently, we worked with one of the customers whose designer launch was painfully slow. The project was a medium sized one and hence the performance degradation was particularly baffling.</P>
<P>To figure out what's wrong, I did an Attach to Process(to debug) with another VS instance to the VS with the workflow designer and turned on all the exceptions. Next, I tried to launch the workflow designer and Whoa…</P>
<P>I am getting hundreds of File IO Not Found Exceptions. No wonder the performance was slow.</P>
<P>I tried compilation of the project to check if the customer is missing something. No, nothing was wrong. The project built successfully. What was happening that directly contributed to the slow designer performance?</P>
<P>The problem is:</P>
<P>If an activity used in a workflow is dependent on Assembly A(uses some types out of A) and Assembly A is dependent on Assembly B; during design time, when you load the workflow, the object instance of&nbsp;each activity in the workflow&nbsp;is created. During this instance creation, CLR wants to ensure that not only the activity assembly, but all its dependent assemblies are loaded(A and B) as well. For this purpose, the VS Type Resolution Service goes through the path where it finds the activity assembly, to look for&nbsp;A and B. It also&nbsp;finally looks up GAC. </P>
<P>If it still doesn't find&nbsp;the assemblies&nbsp;in those paths, then it will do an Assembly.Load for A and B with their partial names. This would mean that if an assembly with Version 1.0.0.0 is not found it will try 1.0.0.1. Similarly, if assembly with culture = neutral is not found, then look for assembly with a specific windows or framework culture. This continues with different variations based on the CLR algorithms for loading assemblies with partial names till they are found. Thus you can imagine the number of File-Not-Founds per assembly and then think about the same with multiple assemblies that are needed and not being found during the workflow design time authoring environment.</P>
<P>Hence, in addition to the tips we talked about in the previous post, please do an Attach To Process to the workflow designer VS instance and see if you have too many File Not Found Exceptions. If so, please ensure the necessary assemblies are in the VS probe path(possibly assembly references in the workflow project or adding to VS(devenv.exe) probe paths) and see if that improves the performance drastically.</P>
<P>In my next post, we will talk about what if none of the solutions we have discussed till date works. Stay tuned!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>WF3 Design Time Performance - I</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/wf3-design-time-performance-i</link>
      <pubDate>Mon, 05 Apr 2010 11:10:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/04/05/wf3-design-time-performance-i/</guid>
      <description><![CDATA[Before, we start talking about the WF3 design time performance, let me clarify some of the...]]></description>
      <content:encoded><![CDATA[<P>Before, we start talking about the WF3 design time performance, let me clarify some of the terminologies: </P>
<P>1. WF3 is the version of Workflow shipped as part of .NET Framework 3.0 and 3.5. Note that WF3 is also shipped as part of .NET Framework 4.0. Meaning, System.Workflow.* assemblies are shipped as part of the latest version of the framework.</P>
<P>2. WF4 is the latest version of Workflows we are shipping first time as part of .NET Framework 4.0. Meaning, System.Activities.* assemblies are shipped for first time in the latest version of framework as well.</P>
<P>Yes, both the versions of WF3 and WF4 are being shipped simultaneously in .NET Framework 4.0. </P>
<P>Now, about the design time performance, yes, we have heard you about the performance issues. In general, the complaint is that the performance of the designers starts decreasing exponentially as the number of activities on the designer starts increasing.</P>
<P>The next few articles, we will talk about how you can improve the performance of the designers as well as see some fixes that we have done to improve the performance.</P>
<P>To start with, one of the white papers about the general Workflow performance has been published in <A href="https://msdn.microsoft.com/en-us/library/aa973808.aspx" mce_href="https://msdn.microsoft.com/en-us/library/aa973808.aspx">here</A>. </P>
<P>A few other tips to keep in mind to improve the Design Time performance are(initially published in a forum post by Lorenz Prem and Ramraj B):</P>
<H6><EM>1. Move all types used in workflows to a different project than where the workflows live. </EM></H6>
<P>Move interfaces, event types, custom activities, helper classes to a different project than in which the workflow resides. E.g. in the solution from a customer, there were about 10 project, with 10 workflows each and 10 associated event types. These types are all reparsed to update to build the design time type information every time the user changes workflows in the project. Moving these to a different assembly e.g&nbsp; just one project with all the types needed for the 10 workflow projects will help improve performance.</P>
<H6><EM>2. Reduce the number of workflows in a project. </EM></H6>
<P>Each workflow is a type ( directly in c#/vb, and indirectly in xoml case) that needs a design time type to be built by parsing, so if there are 10 workfows in a project, opening any workflow in the project for the first time means parsing all the other workflows as well. Classifying these workflows based on their function and grouping them in 2-3 workflows per project improved performance drastically.</P>
<H6><EM>3. Re-Factor large state machine workflows into smaller workflows</EM></H6>
<P>One example we found from a customer had 780 states and 1000 activity binds in the same workflow, leading to a InitializeComponent() of about 16000 lines. Factoring this state machine into smaller reusable workflows will making designer performance much better, and reduce a lot of redundant states.</P>
<H6><EM>4. Don’t do long running work in activity constructors</EM></H6>
<P>Activity constructors are called during design time also, so doing things like connecting to a database etc should never be done in constructors, this can make the designer take too long to open workflow documents using these activities.</P>
<P>Of course, there will be scenarios where the above 4 tips wont solve all/any of your issues with the designer performance. For that, please stay plugged-in for the next few blog posts on this topic:-)</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Mocks for Unit Testing</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/mocks-for-unit-testing</link>
      <pubDate>Sat, 13 Mar 2010 10:37:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/13/mocks-for-unit-testing/</guid>
      <description><![CDATA[This post is not exactly related to Designer, but something I am looking closely into nowadays....]]></description>
      <content:encoded><![CDATA[<P>This post is not exactly related to Designer, but something I am looking closely into nowadays. Recently a customer asked, how can he replace one of his long running activities with a different mock activity so that he can still unit test his workflow/composite activity logic.</P>
<P>Another scenario would be, how to replace an activity which queries a live Db( or does some other Aysnc work) with a test activity which can query a test Db or even a file during testing.</P>
<P>One way is to load the activity in the designer and then use the <A href="https://blogs.msdn.com/kushals/archive/2009/11/11/morphing.aspx" mce_href="https://blogs.msdn.com/kushals/archive/2009/11/11/morphing.aspx">MorphHelper</A> class to replace the long running activity with a mock activity. You can then use wd.Flush(wd is an object of type WorkflowDesigner) and then use the wd.Text to save the updated Xaml into a different file to finally unit test the workflow/composite activity.</P>
<P>The cleaner way though, is something that one of the Devs in our team, Dan Glick, suggested.&nbsp; Instead of loading through the designer and going about multiple steps, the developer/tester can use a custom XamlSchemaContext.</P>
<P>For example: Suppose you want to replace a Prompt activity with an Action activity. Also, to add some complexity to the complexity, assume that Prompt activity has an InArgument&lt;string&gt; UserResponse. However Action has an InArgument&lt;string&gt; but with a different name – UserAction. Meaning, there is no 1:1 correspondence between the arguments/properties between the two activities.</P>
<P>To achieve this replacement, we can write something as follows:</P><PRE class=csharpcode>    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> MySchemaContext : XamlSchemaContext
    {
        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>override</SPAN> XamlType GetXamlType(Type type)
        {
            <SPAN class=kwrd>if</SPAN> (type == <SPAN class=kwrd>typeof</SPAN>(Prompt))
            {
                <SPAN class=kwrd>return</SPAN> <SPAN class=kwrd>new</SPAN> myXamlType(<SPAN class=kwrd>typeof</SPAN>(CustomActivities.Action), <SPAN class=kwrd>this</SPAN>);
                <SPAN class=rem>//return base.GetXamlType(typeof(CustomActivities.Action));</SPAN>
            }
            <SPAN class=kwrd>else</SPAN>
            {
               <SPAN class=kwrd>return</SPAN> <SPAN class=kwrd>base</SPAN>.GetXamlType(type);
            }
        }
    }

    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> myXamlType : XamlType
    {
       

        <SPAN class=kwrd>public</SPAN> myXamlType(Type t, XamlSchemaContext schemaContext):<SPAN class=kwrd>base</SPAN>(t, schemaContext)
        {
            

        }

        <SPAN class=kwrd>protected</SPAN> <SPAN class=kwrd>override</SPAN> XamlMember LookupMember(<SPAN class=kwrd>string</SPAN> name, <SPAN class=kwrd>bool</SPAN> skipReadOnlyCheck)
        {
            <SPAN class=rem>//return base.LookupMember(name, skipReadOnlyCheck);</SPAN>
            <SPAN class=kwrd>if</SPAN> (name == <SPAN class=str>"UserResponse"</SPAN>)
            {
                <SPAN class=kwrd>return</SPAN> <SPAN class=kwrd>base</SPAN>.LookupMember(<SPAN class=str>"UserAction"</SPAN>, skipReadOnlyCheck);
            }
            <SPAN class=kwrd>else</SPAN>
            {
                <SPAN class=kwrd>return</SPAN> <SPAN class=kwrd>base</SPAN>.LookupMember(name, skipReadOnlyCheck);
            }

        }

    }</PRE>
<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>With these two helper classes in place, we now get the new activity object tree that can then be passed to a runtime host and thus unit test the workflow/activity successfully.</P><PRE class=csharpcode>Activity act = ActivityXamlServices.Load(<SPAN class=kwrd>new</SPAN> XamlXmlReader(<SPAN class=str>"myFile.Xaml"</SPAN>, <SPAN class=kwrd>new</SPAN> MySchemaContext()));</PRE>
<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>Hope this helps!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Base Designer with additional adornments II</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/base-designer-with-additional-adornments-ii</link>
      <pubDate>Fri, 12 Mar 2010 12:31:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/12/base-designer-with-additional-adornments-ii/</guid>
      <description><![CDATA[Couple of customers reported an issue with applying additional adornments on the designer discussed...]]></description>
      <content:encoded><![CDATA[<P>Couple of customers reported an issue with applying additional adornments on the designer discussed in this <A href="https://blogs.msdn.com/kushals/archive/2010/01/04/base-designer-with-additional-adornments.aspx" mce_href="https://blogs.msdn.com/kushals/archive/2010/01/04/base-designer-with-additional-adornments.aspx">post</A>. The issue was for out of box activities which didn't have a custom designer(were using the ActivityDesigner) itself, the adornments were not working. An example would be the Delay activity.</P>
<P>Currently, we don't have a clean solution to this as the ActivityDesigner has an implicit style which is picked up by WPF. And if there is such an implicit style, the App.Resources style in our application never gets picked up.</P>
<P>The workaround that we have suggested is to create a simple DerivedDesigner from ActivityDesigner and then apply it on for all types that are using just the ActivityDesigner. This has to be done <STRONG>after loading the Workflow</STRONG> though rather than in the RegisterMetadata section.</P><PRE class=csharpcode>AttributeTableBuilder table = <SPAN class=kwrd>new</SPAN> AttributeTableBuilder();
table.AddCustomAttributes(<SPAN class=kwrd>typeof</SPAN>(Activity), <SPAN class=kwrd>new</SPAN> DesignerAttribute(<SPAN class=kwrd>typeof</SPAN>(DerviedDesigner)));
MetadataStore.AddAttributeTable(table.CreateTable());</PRE>
<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>Hope this helps!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Storing your information into activities during design time</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/storing-your-information-into-activities-during-design-time</link>
      <pubDate>Thu, 11 Mar 2010 20:20:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/11/storing-your-information-into-activities-during-design-time/</guid>
      <description><![CDATA[Continuing with the theme of questions we get from customers: How can we store some specific...]]></description>
      <content:encoded><![CDATA[<P>Continuing with the theme of questions we get from customers: How can we store some specific information into activity. One of the cases might be since we don't provide a unique identifier for an activity, the developer wants to store the unique ids per activity. This way he can differentiate between two activities of the same type in the workflow.</P>
<P>This can be accomplished through the ViewStateService. We already use the ViewStateService per activity to store the Expand/Collapse state of the activity. An additional item in the ViewState dictionary would be its unique identifier. So every time an activity is added to the designer surface, we can do the following in the OnModelItemChanged(fired when the activity is added the first time to the designer) event handler.</P><PRE class=csharpcode><SPAN class=kwrd>this</SPAN>.Context.Services.GetService&lt;ViewStateService&gt;().StoreViewState
(
     <SPAN class=kwrd>this</SPAN>.ModelItem, <SPAN class=str>"myId"</SPAN>, <SPAN class=kwrd>i++</SPAN>
);</PRE><PRE class=csharpcode>As you persist this Xaml, you would see something like below for a leaf activity:</PRE><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>sap:WorkflowViewStateService.ViewState</SPAN><SPAN class=kwrd>&gt;</SPAN>
   <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>scg:Dictionary</SPAN> <SPAN class=attr>x:TypeArguments</SPAN><SPAN class=kwrd>="x:String, x:Object"</SPAN><SPAN class=kwrd>&gt;</SPAN>
        <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>x:String</SPAN> <SPAN class=attr>x:Key</SPAN><SPAN class=kwrd>="myId"</SPAN><SPAN class=kwrd>&gt;</SPAN>22<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>x:String</SPAN><SPAN class=kwrd>&gt;</SPAN>
   <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>scg:Dictionary</SPAN><SPAN class=kwrd>&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>sap:WorkflowViewStateService.ViewState</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<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>
<PRE class=csharpcode>&nbsp;</PRE><PRE class=csharpcode>Hope this helps!</PRE>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Hiding the Breadcrumb</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/hiding-the-breadcrumb</link>
      <pubDate>Thu, 11 Mar 2010 14:53:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/11/hiding-the-breadcrumb/</guid>
      <description><![CDATA[We continue to get requests from customers we didnt anticipate. And we continue to solve those...]]></description>
      <content:encoded><![CDATA[<P>We continue to get requests from customers we didnt anticipate. And we continue to solve those problems – some way or the other. This one is that “some way”. I dont love it. But hey, if it helps the customer, it works.</P>
<P>The customer wanted a way to hide the breadcrumb. Since we didnt have a specific API to do so, we just asked him to do the following:</P><PRE class=csharpcode>FrameworkElement e = <SPAN class=kwrd>this</SPAN>.wd.View <SPAN class=kwrd>as</SPAN> FrameworkElement;
e.Margin = <SPAN class=kwrd>new</SPAN> Thickness(0, -40, 0, -40);
grid1.Children.Add(<SPAN class=kwrd>this</SPAN>.wd.View);</PRE>
<P>
<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>We just moved the Designer View up such that it hides the breadcrumb panel at the top.</P>
<P>Hope this helps!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Icons for the Designer</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/icons-for-the-designer</link>
      <pubDate>Thu, 11 Mar 2010 14:18:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/11/icons-for-the-designer/</guid>
      <description><![CDATA[We have already seen how to have icons for the toolbox items. However, unfortunately, it is not the...]]></description>
      <content:encoded><![CDATA[<P>We have already <A href="https://blogs.msdn.com/kushals/archive/2010/01/04/toolbox-tooltips-and-icons.aspx" mce_href="https://blogs.msdn.com/kushals/archive/2010/01/04/toolbox-tooltips-and-icons.aspx">seen</A> how to have icons for the toolbox items. However, unfortunately, it is not the same way for the icons on the designer surface.</P>
<P>Good news though, it is not that difficult. As we create our ActivityDesigner, we essentially need to add the following property:</P><PRE class=csharpcode><SPAN class=kwrd>&lt;</SPAN><SPAN class=html>sap:ActivityDesigner.Icon</SPAN><SPAN class=kwrd>&gt;</SPAN>
        <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>DrawingBrush</SPAN><SPAN class=kwrd>&gt;</SPAN>
            <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>DrawingBrush.Drawing</SPAN><SPAN class=kwrd>&gt;</SPAN>
                <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>ImageDrawing</SPAN><SPAN class=kwrd>&gt;</SPAN>
                    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>ImageDrawing.Rect</SPAN><SPAN class=kwrd>&gt;</SPAN>
                        <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>Rect</SPAN> <SPAN class=attr>Location</SPAN><SPAN class=kwrd>="0,0"</SPAN> <SPAN class=attr>Size</SPAN><SPAN class=kwrd>="25,25"</SPAN> <SPAN class=kwrd>&gt;&lt;/</SPAN><SPAN class=html>Rect</SPAN><SPAN class=kwrd>&gt;</SPAN>
                    <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>ImageDrawing.Rect</SPAN><SPAN class=kwrd>&gt;</SPAN>
                    <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>ImageDrawing.ImageSource</SPAN><SPAN class=kwrd>&gt;</SPAN>
                        <SPAN class=kwrd>&lt;</SPAN><SPAN class=html>BitmapImage</SPAN> <SPAN class=attr>UriSource</SPAN><SPAN class=kwrd>="Activity-Monitor-icon.png"</SPAN> <SPAN class=kwrd>&gt;&lt;/</SPAN><SPAN class=html>BitmapImage</SPAN><SPAN class=kwrd>&gt;</SPAN>
                    <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>ImageDrawing.ImageSource</SPAN><SPAN class=kwrd>&gt;</SPAN>
                <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>ImageDrawing</SPAN><SPAN class=kwrd>&gt;</SPAN>
            <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>DrawingBrush.Drawing</SPAN><SPAN class=kwrd>&gt;</SPAN>
        <SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>DrawingBrush</SPAN><SPAN class=kwrd>&gt;</SPAN>
<SPAN class=kwrd>&lt;/</SPAN><SPAN class=html>sap:ActivityDesigner.Icon</SPAN><SPAN class=kwrd>&gt;</SPAN></PRE>
<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>Hope this helps!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Binding activity properties to a custom control</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/binding-activity-properties-to-a-custom-control</link>
      <pubDate>Thu, 11 Mar 2010 13:21:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/11/binding-activity-properties-to-a-custom-control/</guid>
      <description><![CDATA[Today, for a re-hosted application, generally users have the Designer, Toolbox and the Property...]]></description>
      <content:encoded><![CDATA[<P>Today, for a re-hosted application, generally users have the Designer, Toolbox and the Property Grid. The property grid provided has been hooked up pretty well with the designer. Thus any changes to the properties of an activity on the designer surface are bound pretty tightly with the property grid properties.</P>
<P>However, what if you have your custom control and you want to bind the changes on the designer surface with that specific custom control.</P>
<P>For example, you have a WPF Textbox in your application and you want to bind the changes to the ‘DisplayName’ property of your selected activity with this ‘Textbox.TextProperty’.</P>
<P>Solution:</P><PRE class=csharpcode><SPAN class=kwrd>this</SPAN>.wd.Context.Items.Subscribe&lt;Selection&gt;(<SPAN class=kwrd>delegate</SPAN>(Selection selection)
{
       Binding myBinding = <SPAN class=kwrd>new</SPAN> Binding();
        myBinding.Path = <SPAN class=kwrd>new</SPAN> PropertyPath(<SPAN class=str>"DisplayName"</SPAN>);
        myBinding.Source = selection.PrimarySelection;
        myTextBox.SetBinding(TextBox.TextProperty, myBinding);

});</PRE><PRE class=csharpcode>&nbsp;</PRE>
<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>Hope this helps!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
    <item>
      <title>Designer in View</title>
      <link>https://docs.microsoft.com/archive/blogs/kushals/designer-in-view</link>
      <pubDate>Thu, 11 Mar 2010 13:04:00 GMT</pubDate>
      <dc:creator><![CDATA[kushals]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/kushals/2010/03/11/designer-in-view/</guid>
      <description><![CDATA[Recently, a customer asked how can we get the designer in focus if we know the Model Item for that...]]></description>
      <content:encoded><![CDATA[<P>Recently, a customer asked how can we get the designer in focus if we know the Model Item for that activity. This can specifically be of value as you are working with large workflows and huge scrolling for going from top to the bottom.</P>
<P>This can now be achieved pretty simple:</P>
<P>modelItem.Focus();</P>
<P>Thus, once you know the model item you want to access, call modelItem.Focus and this should bring it in view and set focus on it.</P>
<P>Another interesting thing that happened when I was cooking up this sample :Essentially, I had a custom designer for an activity with a button on it. In the button click event handler, I was getting hold of the activity’s model item and then:</P><PRE class=csharpcode> <SPAN class=kwrd>using</SPAN> (ModelEditingScope editingScope = <SPAN class=kwrd>this</SPAN>.ModelItem.Root.BeginEdit(<SPAN class=str>"Activities"</SPAN>))
{
        <SPAN class=kwrd>this</SPAN>.ModelItem.Root.Properties[<SPAN class=str>"Activities"</SPAN>].Collection.Add(<SPAN class=kwrd>new</SPAN> Sequence());
        <SPAN class=rem>//Do this multiple times to have scrolls introduced in the designer due to the large workflow size</SPAN>

}</PRE>
<P>Then to set the focus on my activity with button, I did: this.ModelItem.Focus(). However this didn't work. The focus still remained on the last Sequence activity added. The trick was actually to do it this way:</P><PRE class=csharpcode> Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, (System.Action)(() =&gt;
 {
        myItem.Focus();
  }));</PRE>
<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>The reason being, the added model items themselves set the focus on them through an idle. Hence we need to queue up our idle after them. Hence the Dispatcher.Invoke with the action on ApplicationIdle.</P>
<P>Hope this helps!</P>
<P>Thanks,</P>
<P>Kushal.</P>]]></content:encoded>
    </item>
  </channel>
</rss>