J4N
J4N

Reputation: 20761

Show an activity into the designer?

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 The workflow on visual studio

And in my app, I see only that:

App view

Thank you!

Upvotes: 1

Views: 727

Answers (1)

user1228
user1228

Reputation:

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);

Upvotes: 1

Related Questions