Skip to content

Workflow Custom Activity Events

Nearly every example of how to create a custom workflow activity demonstrates the use of the DependencyProperty.  There’s not much new there.  However, few of the examples will show you how to add events to your custom activities.  It’s not that difficult really, they’re still dependency properties with a bit of a spin.  For instance, if you want to implement a MethodInvoking event you can use the following code:

public static DependencyProperty MethodInvokingEvent =

DependencyProperty.Register(“MethodInvoking”, typeof(EventHandler), typeof(NetSendEmailActivity));


Help Your SharePoint User

public event EventHandler MethodInvoking


add { base.AddHandler(MethodInvokingEvent, value); }

remove { base.RemoveHandler(MethodInvokingEvent, value); }


This should look really similar to the structure of a regular DependencyProperty – because it is.  Other than the non-static property and the name of the Dependency property, everything is the same.

For a full fledged example you can look at “Send E-mail Activity Sample” in MSDN.  (This isn’t a complete replacement for the SharePoint SendEmailActivity to resolve the issues mentioned in my previous post, but it’s not a bad start.)

No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this: