In this blog post i am going to build Custom Activity Designer for the Custom Activity which I created in my previous blog post. [http://mstecharchitect.blogspot.com/2010/02/wf-40-custom-code-activity-vsnet-2010.html].
The WF 4.0 Activity Designer is based on WPF ( Windows Presentation Foundation) which means we have all the power of WPFs which is Rich UI , Styling, Data binding,Triggers etc., for our Custom Activity. In addition to this WF also provides some user controls that you can use in your Activity Designer to simplify the task of displaying an individual child activity, or a collection of activities.
The four primary controls are:
Now we are going to add new Item template called [Activity Designer] to our Custom Activity project as shown below.
After adding Activity Designer template we need to Create User Interface in XAML .
Here i am using ActivityDesigner item template to create a UI for custom activity because i have only one Activity in my project. Suppose if you have more number of custom activities you can use WF4 ActivityDesignerLibrary project template. Once we have added the Designer ,now we are ready to customize the look and feel of out custom activity by laying out how to display data and visual representations of child activities. Within the designer you have access to a ModelItem that is an abstraction over the actual activity, and surfacing all properties of the activity.
Once we build the UI now we need to attach designer to our Custom Activity class as shown below.
Now add Custom Activity project as a Reference in Main [hosting] Workflow project & Compile the Custom Activity project. Now this custom activity will appear in Toolbox. now Drag and drop and set the properties for the custom activity.
Since this custom activity returns the List of File names from the given input Directory to store the output result we need to create Workflow variable then to loop through the List of File names add ForEach<String> activity and print the file name using WriteLine Activity.
Now Hit F5 and Run the Main Work Flow project. you will see the Files listed form the given directory as shown below.
For More Info Please Refer the following URI: http://msdn.microsoft.com/en-us/library/ee342461.aspx.