【发布时间】:2015-04-16 14:04:34
【问题描述】:
由于我的应用程序中有一个奇怪的行为,我不得不在调用 WorkflowInvoker.Invoke 之前重新加载设计器。
wd.Flush();
SaveXamlFile(currentXamlPath, wd.Text);
我只是刷新内容,然后将 wd.Text 写入文件。
//cleanup the previous designer
if (wd != null)
{
wd.ModelChanged -= new EventHandler(Designer_ModelChanged);
}
//designer
wd = new WorkflowDesigner();
designerArea.Child = wd.View;
this.DebuggerService = this.wd.DebugManagerView;
//property grid
propertiesArea.Child = wd.PropertyInspectorView;
//event handler
wd.ModelChanged += new EventHandler(Designer_ModelChanged);
//error service
wd.Context.Services.Publish<IValidationErrorService>(errorService);
wd.Context.Items.Subscribe<Selection>(OnItemSelected);
然后我重新创建 WorkflowDesigner 的新实例并加载之前保存的文件。
wd.Load(currentXamlPath);
我调用 WorkflowInvoker.Invoke 并在派生自 CodeActivity 的自定义活动中使用它的名称: 好的,到现在为止还好,我那里有一个 1.2 的 ID。
我想通过它的 ModelItem 更新这个 Activity 的一些字段,以便立即在 GUI 中显示它们。
IEnumerable<ModelItem> activityCollection = currentWorkflow.Find(currentWorkflow.Root, typeof(Activity));
但问题来了:
我在那里找不到我的活动 ID。现在已从 1.2 转换为 2。为什么会这样?
我试图从我的 Activity Execute 方法发送一个 this 引用并通过 ref 搜索它,但我得到的只是空值。
ModelItem temp = activityCollection.FirstOrDefault((m) => (m.GetCurrentValue() == a));
我确定我在这里遗漏了一些东西,但我无法弄清楚它是什么。
【问题讨论】:
标签: workflow workflow-foundation-4 workflow-foundation workflow-activity