In order to implement activity binding between a custom activity and your workflow, the following steps are necessary. It is assumed that you are creating the activity from scratch. However, you may skip to "Prepare your workflow" if you are simply trying to implement Activity Binding to a DependencyProperty.
- Prepare your custom activity
- You must define the property that you want to bind to as a DependencyProperty.
- Prepare your workflow
- In the .designer.cs file, add an ActvityBind entity for the custom activity's property that you exposed.
- Set the Name property of the ActivityBind entity.
- Set the Path property of the ActivityBind entity. The path is essentially name of the publicly visible property that you want to bind to.
- Ensure that the custom activity has been instantiated within your workflow.
- Call the SetBinding method of the instantiated custom activity to bind the property of the activity to the workflow.
Within your MyActivity.cs file, you will have something that looks like the following:
public static DependencyProperty NameProperty =
DependencyProperty.Register("Name", typeof(String),
typeof(MyActivity));
[Description("The description of NameProperty")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
public string Name
{
get
{
return (String)(base.GetValue(MyActivity.NameProperty)); }
set
{
SetValue(MyActivity.NameProperty, value);
}
}
Within the InitializeComponent() of your workflow (in the .designer.cs):
// Setup the binding information
ActivityBind nameActivityBind = new ActivityBind();
nameActivityBind.Name = "MyWorkflow";
nameActivityBind.Path = "Name";
// Setup the link between the workflow and the
// custom property of the custom activity
// Assume that this.activity is an instance of MyActivity
this.activity = new MyActivity();
this.activity.SetBinding(MyActivity.NameProperty,
((ActivityBind)(nameActivityBind)));
1 comment:
Hey Chad,
Nice Post,but could you please explain how to bind parameters between 2 custom activities without bringing in the workflow using the activity bind class
thanks,
Ashwin
Post a Comment