none
Native Activity Template from IActivityTemplateFactory

    Question

  • Can you create a Native Activity template (straight XAML file) from IActivityTemplateFactory, as opposed to a class or Code Activity based one?

    We are going to build a straight XAML workflow and want to make a template out of it.

    Thanks

    Tuesday, November 08, 2011 6:23 PM

Answers

  • Trying to clarify the above, the answer is 'it depends'

    it depends => 'no, not in VS'

    The capability to do it doesn't already exist in VS.

    it depends => 'yes, you can do that - in your own rehosting application'.

    You don't have to design workflows in VS. If you rehost the workflow designer (which takes a few minutes), that capability is not too hard to add to the rehosted app (more than just a few minutes). Check out this old thread for details on how.
    Tim

    Saturday, November 12, 2011 12:56 AM

All replies

  • IActivityTemplateFactory is just for returning one or more activities in an inline fashion, which will be embedded into an existing workflow.

    It doesn't matter whether those activities are CodeActivity or XAML activity - or a tree of activities loaded from XAML - they can be any of these. I think the last of these is what you want to do.

    The trickier part of this is how to generate a factory per xaml file, but there are some solutions involving techniques such as Reflection.Emit to be found in past posts on this forum.

    Tim

    Tuesday, November 08, 2011 11:06 PM
  • Hi,

    Thanks Tim.

    Create a class derived form the interface "IActivityTemplateFactory " and in "Create" method you can build activity from XAML file.

    Use ActivityXamlServices to XAML as activity.

    Activity TempWF;

    Stream wfXaml = File.OpenRead("workflow.xaml");

    TempWF = ActivityXamlServices.Load(wfXaml);

    Return TempWF;

    Thanks,

    Madhur 


    MB
    Wednesday, November 09, 2011 3:02 PM
  • Thanks for the reply.

    Guess I was wondering if could create a template strictly through the designer, but perhaps not.

    Wednesday, November 09, 2011 3:49 PM
  • What does 'strictly through the designer' mean for you - is it the designer in VS, with no custom code at all? A rehosted app, but without fancy code?
    Tim

    Friday, November 11, 2011 9:06 AM
  • If you look at the MSDN example of using the interface, it simply adds a Delay activity for 10 seconds, but it is all done in code.

    Obviously, I can drag a Delay activity into the VS workflow designer and set the duration to 10.  Could I do something like this AND make a template out of it, all within the designer?  In other words, can I tell the VS designer to to use the interface?

    Hope this helps.

    Thanks again

    Friday, November 11, 2011 12:41 PM
  • Trying to clarify the above, the answer is 'it depends'

    it depends => 'no, not in VS'

    The capability to do it doesn't already exist in VS.

    it depends => 'yes, you can do that - in your own rehosting application'.

    You don't have to design workflows in VS. If you rehost the workflow designer (which takes a few minutes), that capability is not too hard to add to the rehosted app (more than just a few minutes). Check out this old thread for details on how.
    Tim

    Saturday, November 12, 2011 12:56 AM