locked
Custom activity with Flowchart behaviour RRS feed

  • Question

  • Want to create a custom activity which can be used for flowcharting.

    Since Flowchart is a sealed class, We tried implementing "IActivityTemplateFactory" and returning a flowchart activity instance, however the custom properties that we have defined in our custom activity are not comming through the property window. We realised that the custom activity is just a flowchart instance.

    How can we get the additional properties and behaviours in the custom activity along with flowchart?

     

    Wednesday, October 27, 2010 4:03 PM

Answers

All replies

  • Hi,

    Could you make it more clear what exactly do you want? If you just want to add some properties to an activity, I think you can use attached property. you can see this blog post for samples: https://blogs.msdn.com/b/mwinkle/archive/2009/12/06/wf4-design-time-attachedpropertiesservice-and-attached-properties.aspx

    If you want to implement your custom activity that looks like flowchart with different behavior, you need start from scratch and build your own version of flowchart. Tim has a series posts about that, you can take a look: http://blogs.msdn.com/b/tilovell/archive/2009/12/31/freeform-custom-activity-designers-using-icompositeview.aspx

    thanks,

    Anders


    This posting is provided "AS IS" and confers no rights or warranties.
    Wednesday, October 27, 2010 4:21 PM
  • Thanks, it helps us.
    Friday, October 29, 2010 12:20 PM
  • For anyone looking further at the 'implement your own flowchart' option, I would also strongly suggest you see the code of State Machine on wf.codeplex.com.
    Tim
    Friday, October 29, 2010 5:49 PM
  • Hi,

    I need to develop a custom activity which contain a FlowChart activity as an inbuilt one. Basically the requirement is to have FlowChart activity as the ROOT activity when the user wanted to create a new WF in the WPF rehosted designer. . . something similar to Sequence activity that is comming as default ROOT activity........ I did achieved this and the following is the sample code.....

    namespace CustomActivities
    {
        [Designer(typeof(CustomActivities.CustActivityDesigner))]
        public sealed class CustActivity : NativeActivity
        {
            [Browsable(false)]
            public Collection<Activity> Activities { get; set; }
        
            public CustActivity()
            {
                Activities = new Collection<Activity>();
                System.Activities.Statements.Flowchart fl = new System.Activities.Statements.Flowchart();

                Activities.Add(fl);
            }
     
            protected override void CacheMetadata(NativeActivityMetadata metadata)
            {
                metadata.SetChildrenCollection(Activities);
            }
     
            protected override void Execute(NativeActivityContext context)
            {
                
            }
        }
    }

     Here the problem is, whenever the workflow is saved and reopened in the WF designer, the FlowChart activity is getting duplicated . . .. because the constructor creates a new FlowChart . .. I don't want this duplicate. How to achieve this ?

     

    Monday, November 8, 2010 1:38 PM