问题
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