Custom Composite Designers - Workflow Item Presenter

The WorkflowItemPresenter is a key type in the WF designer programming model that allows for the creation of a "drop zone" where an arbitrary activity can be placed. This sample shows how to build an activity designer that surfaces such a "drop zone."

This sample demonstrates:


  • Creating a custom activity designer with a WorkflowItemPresenter.

  • Registering the custom designer using the metadata store.

  • Programming the rehosted toolbox declaratively and imperatively.

Sample Details

The code for this sample shows:

  • The custom activity designer is built for the SimpleNativeActivity class.

  • The creation of a custom activity designer with a WorkflowItemPresenter.

<sap:ActivityDesigner x:Class="Microsoft.Samples.UsingWorkflowItemPresenter.SimpleNativeDesigner"
        <DataTemplate x:Key="Collapsed">
                <TextBlock>This is the collapsed view</TextBlock>
        <DataTemplate x:Key="Expanded">
                <TextBlock>Custom Text</TextBlock>
                <sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Body, Mode=TwoWay}"
                                        HintText="Please drop an activity here" />
        <Style x:Key="ExpandOrCollapsedStyle" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate" Value="{DynamicResource Collapsed}"/>
                <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="true">
                    <Setter Property="ContentTemplate" Value="{DynamicResource Expanded}"/>
        <ContentPresenter Style="{DynamicResource ExpandOrCollapsedStyle}" Content="{Binding}" />

Note the use of WPF data binding to bind to ModelItem.Body. ModelItem is the property on ActivityDesigner that refers to the underlying object the designer is being used for, in this case, SimpleNativeActivity.

To setup, build, and run the sample

  1. Open the solution in Visual Studio 2010.

  2. Press F5 to compile and run the application.


The samples may already be installed on your machine. 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.


See also