10/06/2012

Building a Composite Activity Designer part(1 - 4)

We will learn how to create a composite activity designer. We will use the metadata stored to override the designer of an activity from the workflow activity library. Also, We will add a text box in the hosted workflow designer to display the XAML source code while creating a workflow.
Default designer vs. Composite designer
Default designer vs. Composite designer


Step 1 : Creating a Designer for the TryCatch Built-in Activity
We will open the starting solution for the exercise and create a designer for the TryCatch activity provided in the Activity Library.
  1. Open Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft Visual Studio 2010.
  2. Open the project from last post Adding Controls to an Activity Designer 
  3. Add a new Activity Designer. To do this, right-click the CustomActivities project and select Add | New Item. In the Add New Item dialog box select the Workflow category and select the Activity Designer template. Set the name to MyTryCatchFinally.xaml and click Add. The activity designer will open automatically.
    Adding an Activity Designer (C#)
    Adding an Activity Designer (C#)

    Adding an Activity Designer (Visual Basic)
    Adding an Activity Designer (Visual Basic)
    1. Create the designer for the TryCatch built-in activity. To do this, open the MyTryCatchFinally in the XAML editor, and add the following code (shown in bold) removing the tags.
      XAML
      <sap:ActivityDesigner ...>
          <StackPanel>
              <Border BorderBrush="Green" BorderThickness="4" CornerRadius="5">
                  <sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Try, Mode=TwoWay}" HintText="Insert Try Activities Here"/>
              </Border>

              <Border BorderBrush="Black" BorderThickness="4" CornerRadius="5">
                  <sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Finally, Mode=TwoWay}" HintText="Insert Finally Activities Here"/>
              </Border>
          </StackPanel>
      </sap:ActivityDesigner ...>
      The activity designer should look similar to the following figure:
    2. Creating the activity designer
      Creating the activity designer
      1. Save the activity and close the file.

      No comments:

      Post a Comment