[WF3/3.5]Using InvokeWorkflowActivity - Set sub workflow parameters in the invoking event handler

To use InvokeWorkflowActivity, see Using the InvokeWorkflowActivity Activity The only thing we need to do is assign a workflow type to the TargetWorkflow property of InvokeWorkflow activity.

Once we set the TargetWorkflow property, the Properties panel will be updated and the sub-workflow's dependence properties will show up in the Properties panel of InvokeWorkflowActivity.

We can set static values for these properties or bind each property to a property in the current workflow. Since the sub-workflow instance will executes on its own thread, you cannot retrieve sub-workflow output from its parents workflow.

InvokeWorkflowActivity also provide a invoking event handler for set sub workflow parameters in code. But I can not find any documents or blog articles talk about how to set parameters in the invoking event handler, So after some research and test, I wrote this code and it works:

        private void invokeWorkflowActivity1_Invoking(object sender, EventArgs e) {

            var parameterBindings = this.invokeWorkflowActivity1.ParameterBindings;

            parameterBindings[0].Value = "value of parameter";


Hope this will be helpful to you.

PS: Question from MSDN forum:
InvokeworkFlow Activity in Windows WorkFlow Foundation

blog comments powered by Disqus