Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3311196
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:50:55+00:00 2026-05-17T21:50:55+00:00

I’m creating an application that rehost workflow designer. What I did is following the

  • 0

I’m creating an application that rehost workflow designer. What I did is following the tutorial from Apress’ Pro WF 4 books.

The principle of the tutorial is:
1. Use WorkflowDesigner class to read workflow xaml file, and bind WorkflowDesigner.View and PropertyView property into ContentControl in the UI.
2. Use System.Activities.Presentation.Toolbox.ToolboxControl class to create VS-like Toolbox so that user can drag-and-drop whatever activities that added into this toolbox
3. ToolboxControl uses ToolboxCategory and ToolboxItemWrapper to construct its content.

Okay, my question is here related to ToolboxItemWrapper class. Based on the documentation, the constructor is using a Class Type, not an Instance. So when we drag and drop, it will instantiate the class into an instance.
Here is the documentation:
http://msdn.microsoft.com/en-us/library/system.activities.presentation.toolbox.toolboxitemwrapper.aspx

However, what I want to hack ToolboxItemWrapper so that it can accept an instance, then when we drag and drop it into WorkflowDesigner.View, the View will show the instance.

Any idea or clues how to achieve this functionality?

Reason why I need this feature:
We want to make it easier for user when adding an ‘instance’ into the designer. when you have a ‘type’ in toolbox, after dragging and dropping you need to setup the parameter. When we have ‘instance’ in toolbox, what user needs to do is just dragging and dropping and that’s all. No need to enter parameter to set the ‘type’. Less steps for user when creating their workflow.

Another constraint is the list of activities in the toolbox depends on a specific module. This specific module will generate a list of instances. Then I want to convert these generated instances into entries in toolbox. I’ll add this info on the questions

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:50:55+00:00Added an answer on May 17, 2026 at 9:50 pm

    After doing some investigation, Reflection and IActivityTemplate can help to overcome the instance constraint.

    The sample code are below, credit to Anders Liu from MSDN Forum

  2. Write a class called DynamicActivityTemplate that implement IActivityTemplateFactory. Its impelementation looks like:
  3.     public abstract class DynamicActivityTemplateFactory : IActivityTemplateFactory
         {
          public virtual string GetActivity()
          {
           return null;
          }
    
          public System.Activities.Activity Create(System.Windows.DependencyObject target)
          {
           return XamlServices.Load(new StringReader(GetActivity())) as Activity;
          }
         }
  4. When you get your generated activity instances, for each of them, you need dynamically create a Type that inherite from DynamicActivityTemplateFactory. Every type override the method GetActivity() and returns its instance’s xaml. Following is a sample of how to create such dynamic type:
  5. 
       AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("GeneratedActivities"), AssemblyBuilderAccess.RunAndSave);
       ModuleBuilder mb = ab.DefineDynamicModule("GeneratedActivities", "GeneratedActivities.dll");
       TypeBuilder tb = mb.DefineType("ActivityTemplateFactory4Sequence", TypeAttributes.Public | TypeAttributes.Class, typeof(DynamicActivityTemplateFactory));
       MethodBuilder methodb = tb.DefineMethod("GetActivity", MethodAttributes.Public | MethodAttributes.Virtual, typeof(string), null);
       ILGenerator msil = methodb.GetILGenerator();
       msil.Emit(OpCodes.Ldstr, XamlServices.Save(new Sequence() { DisplayName = "Test" }));
       msil.Emit(OpCodes.Ret);
       Type t = tb.CreateType();
       ab.Save("GeneratedActivities.dll");
       Assembly.Load(new AssemblyName("GeneratedActivities"));

    toolbox.Categories[0].Add(new ToolboxItemWrapper(t));

  6. Add those dynamic generated types to toolbox.
  7. In this case, you create factory types for each of those instances, and then use these factories in toolbox. These factorys will create activities when they are droped to designer. I think this would work for your case, hope it helps.

    Original post from MSDN forum:
    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/1b756014-72a0-483f-99ef-4f9e6e2e2324

  • 0
  • Reply
  • Share
    Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp
    • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.