代码之家  ›  专栏  ›  技术社区  ›  Louis Rhys

如何创建可以包含子活动的活动设计器?

  •  4
  • Louis Rhys  · 技术社区  · 15 年前

    例如,如果您创建自己的名为Run10Times的活动,该活动运行其子活动10次,那么您是否可以拥有一个设计器,该设计器包含一个画布,用户可以将子活动放置到其中?

    1 回复  |  直到 15 年前
        1
  •  7
  •   Maurice    15 年前

    您需要将WorkflowItemPresenter控件添加到活动设计器中。

    假设您有这样的活动:

    [Designer(typeof(MyCompositeDesigner))]
    public class MyComposite : NativeActivity
    {
        public Activity Body { get; set; }
    
        protected override void Execute(NativeActivityContext context)
        {
            context.ScheduleActivity(Body);
        }
    }
    

    <sap:ActivityDesigner x:Class="WorkflowConsoleApplication3.MyCompositeDesigner"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation">
        <StackPanel>
            <TextBlock Text="Activity to execute:" 
                       Margin="6"/>
            <sap:WorkflowItemPresenter Item="{Binding Path=ModelItem.Body, Mode=TwoWay}" 
                                       HintText="Drop Activity" 
                     />
        </StackPanel>
    </sap:ActivityDesigner>
    
    推荐文章