在设计时在自定义活动中输入数据 (WF 4.0)

发布于 2024-08-03 19:38:54 字数 352 浏览 5 评论 0原文

我想更好地了解在设计时使用 WF 4.0 中的自定义活动可以完成的功能和限制。更具体地说,我们可以在自定义活动中做什么,以便允许设计者在设计时以自定义方式进行交互,以指定有关活动的详细信息/数据。

例如,我想创建一个活动 A,当工作流设计器将该活动放置在设计器(Visual Studio 设计器或单独应用程序中的重新托管设计器)的工作流中时,可以显示一个 .NET 对话框它允许用户输入数据(例如,通过“打开文件”对话框指定文件)并验证输入数据,即每当聚焦特定文本框或输入数据(事件处理程序)时运行一些代码。

这可以完成并存储在工作流 XAML 文件中吗?

请注意,当实际设计工作流时,工作流设计器需要所有这些功能。

谢谢。

I want to better understand the capabilities and limitations of what can be done with custom activities in WF 4.0 at design time. More specifically, what we can do in a custom activity such that we can allow the designer to interact in a customized way at the design time for specifying details/data about an activity.

For example, I would like to create an activity A, and when the workflow designer places that activity in a workflow in the designer (either Visual Studio designer or a re-hosted designer in a separate application), a .NET dialog can be shown that lets the user enter data (e.g. specify a file through Open File dialog) and validates input data i.e. runs some code whenever a particular text box is focused or data entered (event handlers).

Can this be done and stored in the workflow XAML file?

Please note that all this capability is required in a workflow designer when a workflow is actually being designed.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

已下线请稍等 2024-08-10 19:38:54

WF4的设计师还是很有能力的。您可以向设计器添加控件,允许最终用户直接与设计图面交互,而无需使用属性表。您还可以向活动添加验证以检查输入的数据是否可接受。所有这些都是在 C# 或 VB 代码的活动级别完成的,而不是在工作流级别完成的。我不确定活动被取消时的事件,但相信它们也得到支持(至少在 Wf3 中它们,我希望它能够继续下去。

The WF4 designer is quite capable. You can add controls to the designer allowing the end user to interact with the design surface directly without using the property sheet. You can also add validation to activities to check if the data entered is acceptable or not. All of this is done at the activity level in C# or VB code, not at the workflow level. I am not sure about events when an activity is dropped but believe they are also supported (they where in Wf3 at least and I would expect that to be carried forward.

空城之時有危險 2024-08-10 19:38:54

该视频讨论了如何创建自定义活动(带有文本框),以便您可以在设计时输入值。希望这对您有帮助。

http://bloggersguides.net/media/p/188.aspx

This video talks about how to create custom activities (with textbox) so that you can put the values in design time.. hope this helps u..

http://bloggersguides.net/media/p/188.aspx

韬韬不绝 2024-08-10 19:38:54

将活动添加到工作流程时,您可以通过多种方式挂钩事件通知。

第一个是监听WorkflowDesigner类(Beta1)上的TextChanged事件或者我认为会有一个ModelChanged事件(Beta2中),这更可靠。这是一条通知,表明您的工作流程中某些内容发生了变化。没什么特别的,只是一些东西,但您可以使用它作为触发器来遍历您的工作流程并查找新的、未配置的活动。

第二种可能性是利用每个 ModelItem(它是活动的设计时包装器)实现 INotifyPropertyChanged 的​​事实。您可以侦听特定属性(例如 While 活动的“主体”)的更改,而不是侦听整个工作流程中的更改 - 然后当属性初始化以保存新活动时,响应更改。

第三种可能性是您感兴趣的活动有一个自定义设计器(您编写的) - 听起来这个场景符合您的想法。在这里您可以完全自定义活动的外观。自定义设计器实际上只是一个 WPF 控件。您可以使用设计 WPF 应用程序时应用的相同事件以及数据绑定和验证技术,或者响应正常的 WPF 事件。如果您愿意,您当然可以弹出对话框。

至于存储在 XAML 文件中,当然自定义活动及其所有配置的属性都保存在 XAML 文件中 - 就像常规活动一样。当您想要再次加载 XAML 文件时,您确实需要提供有关包含 XAML 文件引用的活动的程序集的上下文信息。在 VS 中,这就像添加程序集引用一样简单,在重新托管场景中,您将编写一些代码来执行此操作。

您可能想在 .NET Framework 4:工作流基础 - Beta 1 论坛上找到更多相关信息或提出类似问题

There are a few ways you could hook in to event notifications when an activity is added to your workflow.

The first one is listening to the TextChanged event on the WorkflowDesigner class (Beta1) or I think there is going to be a ModelChanged event (in Beta2), which is more reliable. This is a notification that something has changed in your workflow. Not anything in particular, just something, but you could use this as a trigger to traverse your workflow and look for new, unconfigured activities.

A second possibility is taking advantage of the fact that each ModelItem (which is the design-time wrapper for an activity) implements INotifyPropertyChanged. Instead of listening for changes in the whole workflow, you could listen for changes on specific properties, such as the 'Body' of a While activity - then when the property gets initialized to hold a new activity, respond to the change.

A third possibility is that the activity you are interesting in has a custom designer (which you write) - and it sounds like this scenario matches what you are thinking of. Here you can fully customize the appearance of your activities. The custom designer is really just a WPF control. You can use the same events and databinding and validation techniques that apply when designing a WPF application, or respond to normal WPF events. You can certainly pop up dialogs if you wish to.

As for being stored in XAML files, of course custom activities are saved in XAML files along with all their configured properties - just like regular activities. When you want to load the XAML file again, you do need to provide context information about the assemblies holding the activities referenced by the XAML file. In VS this is as easy as adding assembly references, in rehosting scenario you would write a little code to do this.

You might like to find more about this or ask similar questions on the .NET Framework 4: Workflow Foundation - Beta 1 Forum

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文