NativeActivity/how activity drop? RRS feed

  • Question

  • Hello,

    Here is simple Test Activity class

    public sealed class Test : NativeActivity {

         public Activity Body { get; set;}

         protected override void Execute(NativeActivityContext context)

                 if(Body != null) {

                    // Do whatever from the Body activity




    I dropped this activity on my workflow...then how do I set the Body from designer?

    I thought that I could drag some activity(ex, WriteLine) and drop on this Test activity to set the Body..However, it didn't work.

    In the Properties window, Body is there under Misc section. I am not sure how I set an activity to the Body property.

    Please help me some step how to do this.


    Tuesday, February 28, 2012 9:47 PM


  • Hi,

    In this case, we'll need to create a custom activity designer, bind a WorkflowItemPresenter in the designer to the Body to enable editing it.

    <!-- Copyright (c) Microsoft Corporation. All rights reserved -->
    <sap:ActivityDesigner x:Class="Microsoft.Samples.UsingWorkflowItemPresenter.SimpleNativeDesigner"
        xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="300" d:DesignWidth="300">
            <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}" />

    Then, you can decorate the activity:


    public sealed class Test : NativeActivity {


    For the detailed information, you can refer to

    Custom Composite Designers - Workflow Item Presenter


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by LeoTang Tuesday, March 6, 2012 9:07 AM
    Thursday, March 1, 2012 10:21 AM