Custom Workflow State

Hi

I wanted to create a custom State (derived from StateMachineWorkflowActivity) and then create 2 eventDriven Events inside my custom State hooked up to 2 events on my local services. But the workflow designer does not allow me to drag and drop the EventDriven Events inside my custom state.

1. Is this possible

2. Am i going about it the wrong way. Can i create these events in the code behind

Thanks

Nitin Mistry

Canada




Answer this question

Custom Workflow State

  • Tarey Wolf

    Elif,

    Thanks a lot. Absolutely it was very helpful. Is there any documentation available on the Toolbox item

    I've used code like

    [ToolboxItem(typeof(EmailStateboxItem))]

    [ToolboxBitmap(typeof(EmailState), "Resources.State.ico")]

    and i'm not quite sure what all the other custom attributes are used for.

    Thanks a lot

    Nitin



  • saurabh1531

    First of all you have to derive from StateActivity not StateMachineWorkflowActivity if you want to do a custom state activity.

    And then you have to go to the code beside (the .cs file not .Designer.cs file i am assuming you are using C#) then write you custom toolbox item for that and add the custom toolbox item as the ToolBoxItem attribute for the custom state activity. In the custom toolbox item class you have to override the CreateComponentsCore method.

    For example:

    [ToolboxItem(typeof(MyToolboxItem))]

    public partial class CustomState: StateActivity

    {

    .....

    }

    ...

    public class MyToolboxItem: ActivityToolboxItem

    {

    override IComponent[] CreateComponentsCore(IDesignerHost host)

    {

    CustomState act1 = new CustomState();

    //over here create and add the eventdriven activities to your custom state activity act1

    return (IComponent[]) new IComponent[] { act };

    }

    }

    Hope this helps

    Thanks

    Elif



  • Ric Bevan

    Elif

    much appreciated. Thank you!!



  • luai7

    You can find some nice content - books- at this link

    http://wf.netfx3.com/content/resources.aspx

    Also when you open the Visual Studio 2005 documentation you can see the help document for Windows Workflow Foundation among one of those tabs too. Look for creating custom activities under

    Windows Workflow Foundation

    Windows Worklfow Foundation Programming

    Develiping Workflow Activities

    Creating Custom Activities

    and you will be able to see all the attributes over there.

    Thanks

    Elif



  • Custom Workflow State