Windows Workflow Foundation (WF4) - Custom Activity Designer

This sample demonstrates how you can build a custom activity and activity designer along with tips for supporting images, toolbox icons and debugging. 

C# (311.6 KB)
5 Star
6,992 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Variables
    2 Posts | Last post May 08, 2017
    • Why I can not add a new variable? Like I can add an argument...
    • You can but only for some activities. For example add Sequence and make sure is selected. Now you can add a new variable whose Scope is the Sequence.
  • Loading Sub WorkFlows
    1 Posts | Last post February 19, 2014
    • Is it possible to Load A Xaml Workflow inside Another Xaml Work Flow As Sub Workflow in Designer ? if it's possible how can I Do That ?
  • State Machine
    1 Posts | Last post February 17, 2014
    • I wander if it's possible  to know How can i Use State Machine in Toolbar , i try some files contains state machine and the program works and show me the state machine but the time i want to add state machine elements it's not working what should i write here to add state machine to ToolBar
       toolboxControl.Categories.Add(new ToolboxCategory("Shahram Category")
                  new ToolboxItemWrapper(typeof( "what to add here"    ))
  • Switch from VB to C# in workbenchDesigner
    1 Posts | Last post December 09, 2013
    • this designer project gets expressions in vb language format, but how can i change it to C#?
      i try to do this by creating another template.xaml file in c#, but when i run the project, it still shows expressions in vb.
  • How could have Visual Studio webform Toolbox in wpf Application individual?
    1 Posts | Last post July 28, 2013
    • could I  create WPF app that create WebForm Designer toolbox and then save output in Xml,aspx file or any other format that is possible.
      I want to create a designer like  "Web Form Designer" of Visual Studio IDE in WPF App.
      Could I do this like somethnig you do in this sample? If not,what is your suggestion for my senario.
  • Adding custom activity to a workflow
    1 Posts | Last post February 19, 2013
    • Ron,
      I'm relatively new to workflow and I'm trying to build a custom activity to send an email that can be used across different workflows. I created such custom activity using this sample but when I try adding it to the toolbox of my workflow project it tells me that it can't add it to the designer because it's not compatible. What am I missing?
  • Why does MyActivityLibrary need image link?
    1 Posts | Last post August 01, 2012
    •   public static void RegisterMetadata(AttributeTableBuilder builder)
                  ToolboxBitmapAttribute tba = GetToolboxBitmapAttribute("QuestionMark.png");
                          new DesignerAttribute(typeof(MyActivityDesigner)),
                          new DescriptionAttribute("My sample activity"),
              private static ToolboxBitmapAttribute GetToolboxBitmapAttribute(string imagename)
                  Bitmap img = null;
                  string resourceName = string.Format("{0}.g.resources", typeof(MyActivityDesigner).Assembly.GetName().Name);
                  Stream stream = typeof(MyActivityDesigner).Assembly.GetManifestResourceStream(resourceName);
                  if (stream != null)
                      using (ResourceReader resReader = new ResourceReader(stream))
                          foreach (DictionaryEntry resourceEntry in resReader)
                              string key = resourceEntry.Key.ToString().ToLower();
                              if (key == imagename.ToLower())
                                  img = Image.FromStream(resourceEntry.Value as Stream) as Bitmap;
                  if (img != null)
                      var tbaType = typeof(ToolboxBitmapAttribute);
                      var imageType = typeof(System.Drawing.Image);
                      var constructor = tbaType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { imageType, imageType }, null);
                       return constructor.Invoke(new object[] { img, img }) as ToolboxBitmapAttribute;
                  return null;
  • Multiple Exit paths
    2 Posts | Last post June 15, 2012
    • Hi Ron, I can't stress enough how thankful I am with your posts. You've really helped me with my project. 
      I have a question though. Based on this sample, the user is only allowed to connect the custom activity to another activity. Would it be possible to have 2 or more exit connectors (e.g. FlowDecisions). Hoping for your response. Thanks!
    • The multiple exit paths work only because of the FlowChart control.  The parent activity has to understand how to deal with multiple paths.
  • Dynamic Arguments Designer
    1 Posts | Last post January 05, 2012
    • I have been searching web for a dynamic arguments designer example for a long time (either WPF-based activity designer or Property Grid extension). In your DynamicArguments sample project, you presented MethodInvoke activity which supports dynamic arguments. Unfortunately, you have defined the test workflow it in the code rather than in xaml. I also found another example - ExecuteSqlQuery from ADO.NET Activity Pack, that supports dynamic arguments as well. It has this nice dialog for Parameters property that pops up when you click the ellipses button next to Parameters property in Property Grid. However, I couldn't find the source code for that Property Grid extension.
      The Dynamic Arguments feature is very useful and can be used in many activities. So could you please provide an example of building such a designer, should it be WPF-based activity designer or Property Grid extension?
      Thank you.