具有ActivityActions的自定义活动设计器 [英] Custom activity designer with ActivityActions

查看:70
本文介绍了具有ActivityActions的自定义活动设计器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我一直在努力寻找以下问题的答案,但没有成功.我需要为具有活动委托的活动创建自定义设计器,例如:

I have been trying to find answer to the following problem for hours, without success. I need to create a custom designer for an activity which has activity delegates, for example:

    Public Class SomeActivity
        Inherits NativeActivity

        Public Property Foo As ActivityAction(Of String)
        Public Property Bar As ActivityAction(Of String)

        Protected Overrides Sub Execute(context As NativeActivityContext)
        End Sub
    End Class

使用WF4.5时,此类活动的默认设计器简直很棒.设计器会自动为活动委托创建视图,并允许用户定义委托变量的名称:

When using WF4.5, the default designer for activities like this is simply awesome. The designer automatically creates views for activity delegates and allows the user to define names for delegate variables:

这绝对是绝妙的,适用于大多数情况.但是,我没有发现任何提示如何向这样的设计师添加其他内容.如果创建自定义设计器,则会丢失自动为代表生成的演示者:

This is absolutely brilliant and works for most of the cases. However, I have not found any hint how to add additional content to  a such designer. If I create a custom designer, I lose the automatically generated presenters for delegates:

<sap:ActivityDesigner x:Class="ActivityDesigner1"
    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"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">
    <Grid>
        <Label>Hello, world!</Label>
        <!--What to insert here to include activity delegates?-->
    </Grid>
</sap:ActivityDesigner>

结果没有委托,因为原始设计器已替换为网格:

The result does not have delegates, as the original designer is replaced with the grid:


很明显,我可以使用WorkflowItemPresenter并绑定到适当的处理程序,但是我需要从头开始构建所有内容:

I can, obviously, use WorkflowItemPresenter and bind to appropriate Handlers, but I need to build everything from scratch:

<sap:ActivityDesigner x:Class="ActivityDesigner1"
    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"
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">
    <StackPanel>
        <Label>Hello, world!</Label>
        <Label>Foo</Label>
        <sap:WorkflowItemPresenter Item="{Binding Path=Foo.Handler}" HintText="Drop here"/>
        <Label>Bar</Label>
        <sap:WorkflowItemPresenter Item="{Binding Path=Bar.Handler}" HintText="Drop here"/>
    </StackPanel>
</sap:ActivityDesigner>

这基本上可以正常工作,但是无法像默认活动设计器中那样定义活动变量名称:

This works basically, but there is no way to define activity variable names as in the default activity designer:

我可以破解一些东西以重新实现默认活动设计器中似乎很好实现的东西.不幸的是,这感觉就像是在重新发明方形齿轮...

I could hack in something to re-implement what seems to be so well implemented in the default activity designer. Unfortunately this feels like re-inventing the square wheel...

问题是:是否可以创建一个包含以下内容的自定义活动设计器: 两者都是一些自定义内容还是为活动代表自动生成的占位符?任何提示或示例,我们将不胜感激.

So to the question: is it possible to create a custom activity designer which includes both some custom content and the automatically generated placeholders for activity delegates? Any hints or examples are greatly appreciated.

亲切的问候,

Heikki

推荐答案

请参考示例:

#如何使用Windows Workflow Foundation(WF4)创建自定义活动设计器

#How to create a Custom Activity Designer with Windows Workflow Foundation (WF4)

#如何:创建自定义活动设计器 https://msdn.microsoft.com/zh-CN/library/dd489419(v = vs.100).aspx

#How to: Create a Custom Activity Designerhttps://msdn.microsoft.com/en-us/library/dd489419(v=vs.100).aspx


这篇关于具有ActivityActions的自定义活动设计器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆