In Windows Workflow Foundation 3.x, you used to be able to create a BaseWorkflow class where you could define some properties in that workflow.
And then when you create a workflow you can say it derives from BaseWorkflow class so it inherits all the properties from the base workflow.
Can we achieve the same thing in Windows Workflow Foundation 4 (WF 4)? Like defining InArgument and OutArgument on a BaseActivity then create another Activity that derives from the BaseActivity.
I tried by modify the XAML from let’s say <Activity></Activity> to like <BaseActivity></BaseActivity> … that was the way we did it in WF 3.x.
It doesn’t seem to work in WF 4.
Found a solution to this. It’s actually quite easy. The class generated by the XAML declaration is marked as
partialso you can create a class (also markedpartial) for your activity (workflow) base. Then in XAML, just change the class attribute on your activity to the full namespace of the class you just created.Base Activity Example:
XAML example:
With this method, you can define both in and out arguments on the base class and they show up for your derived activities as well.