locked
How do I create custom activity that users can add children to?

    Question


  • Is it possible for you to expand on how to implement this?  I'm basically doing the same thing: I'm trying to write a custom activity for document approval and want to let the user populate the if/else branchs for approval or deinal of a document.  The activity first has a CallExternalMethod activity and HandleExternalEvent that goes out and gets a response from the user followed by the IfElseActivity.  In my If/Else activity the conditions for each branch are already set, but the child activities of each branch need to be populated with activities.  In my designer I just want to show the activity with 2 children sequence activities which can be populated with activities and hide the CallExternalMethod and HandleExternalEvent.  I've done this by creating a designer for my SubmitForApproval activity that inherits from FreeformActivityDesigner and has a toolbox item that adds two custom sequence activities to it.  So my designer looks and acts like I want it to but my question is this:  How do I associate whats placed in my custom sequence activities (my custom branches) and associate them with the branch activites in my ifElse?

    If I'm creating my custom sequence activities in the toolboxitem class to display in my designer, how can I associate those back to my custom activity?
    Thanks for any Help,

    Tony

    Split from the thread at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=232442&SiteID=1.
    Wednesday, December 19, 2007 4:29 PM

Answers

  • If you custom activity has built in children, when it is used you won't be able to add additional children.  The way you can have pre-configured activities and allow additional children is to use a custom toolboxitem class to compose the activity when the user drags it from the toolbox.  There are several threads about how to do this, let me know if you need some help finding them.  One option, which you have stated is to create a custom designer to only show those activities you want to expose to the user.  Another option is to build the functionality of the CallExternalMethod, HandleExternalEvent and IfElse activities into you custom activity and just have a custom toolbox item that adds the two branches, like the parallel and ifelse activities do.  The activity that I posted on the thread at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2504440&SiteID=1 will give you the IfElse execution logic and the sample at http://wf.netfx3.com/files/folders/activity_behavior/entry838.aspx should help you build in the logic for receiving events.
    Thursday, December 20, 2007 7:44 AM