Show an activity into the designer?

做~自己de王妃 提交于 2019-12-24 06:49:07

问题


I've a sample workflow application, which only have to display an activity an show on which step we are.

The problem is that when I load my activity like this:

TestWorkflow workflow = new TestWorkflow();
_workflowApplication= new WorkflowApplication(workflow );
_workflowDesigner = new WorkflowDesigner();
_workflowDesigner.Load(workflow );
uxGridWorkflowHoster.Children.Add(_workflowDesigner.View);

I'm getting only the root element "sequence" in my box. how to change that?

I get that on visual studio

And in my app, I see only that:

Thank you!


回答1:


The problem is that TestWorkflow doesn't have a designer associated with it, and the design surface doesn't realize that TestWorkflow is an Activity that is composed out of other activities, and it should display the root of its implementation rather than the TestWorkflow activity itself.

I don't know the best way to deal with this, but I've used the following hack. It gets the first activity (the root) of TestWorkflow and wraps it in an ActivityBuilder.

var rootActivity = WorkflowInspectionServices
                       .GetActivities(new TestWorkflow())
                       .FirstOrDefault();

var builder = new ActivityBuilder
              {
                  Implementation = rootActivity,
                  //Name = PartType.Name (whoops, should have cut that out)
              };
_workflowDesigner.Load(builder);


来源:https://stackoverflow.com/questions/5648672/show-an-activity-into-the-designer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!