This documentation is archived and is not being maintained.

CommentOut Activity

This topic applies to Windows Workflow Foundation 4 (WF4).

This sample demonstrates how to write a custom activity that removes other activities from the path of execution, effectively commenting them out.

The CommentOut Activity

To achieve its goal, the CommentOut activity derives from the CodeActivity base class and implements an empty Execute method.

        protected override void Execute(CodeActivityContext context)

The class is declared as shown in the following example.

    public sealed class CommentOut : CodeActivity

The Designer attribute specifies the class that implements the visual interface of the activity at design time. The ContentProperty attribute declares that the “Body” property can be skipped in the XAML representation of an instance of this activity.

<Border x:Uid="Border_1" BorderThickness ="1">
    x:Uid="sad:WorkflowItemPresenter_1" AutomationProperties.AutomationId="Body" Item="{Binding Path=ModelItem.Body, Mode=TwoWay}"
    AllowedItemType="{x:Type sa:Activity}"
    HintText="Drop activity here" 
    Margin="5,5,5,5" />

In the designer class, XAML is used to create a custom visual representation of the activity. WorkflowItemPresenter is a class that provides the visual editor.

A single activity can be dropped onto the CommentOut activity surface. If you want to add multiple activities to this surface, drag a sequence activity here first.

To use this sample

  1. Open CommentOut.sln in Visual Studio 2010.

  2. Compile the solution by pressing CTRL+SHIFT+B.

  3. Start the sample without debugging by pressing CTRL+F5.

Ee661651.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing.


If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.