Answered by:
Rehosting question - where is the Arguments button?

Question
-
When the WF designer is used in VS 2010, there is an Arguments button next to the Variables button. However, when the WF designer is rehosted (as in the WF exercises), the Arguments button is not present. Is this a bug, or intentional?Monday, July 6, 2009 5:25 PM
Answers
-
Certainly, and check out the blog post I put up here.
The WF Designer is an editor of instances, that is I must always edit an instance of a type. When one is creating a new activity, you are actually creating a new type (this is what we will refer to as the x:Class case, because the xaml looks like <Activity x:Class ). In order for our editor to work, we actually can't edit an instance of that new type, because you are creating and configuring a type, not an instance of a type. So we have ActivitySchemaType which serves as an instance of a type description, and that is what you edit.
Now, if you are rehosting, and you decide you want to do WorkflowDesigner.Load(new Sequence... ) you are simply editing an instance of the Sequence type, and in that case, you can't add arguments, you are just configuring a sequence, and indeed, the xaml for that would look like
<Sequence>
<Persist />
<WriteLine Text="[DateTime.Now]" />
....
However, if you want to edit a type definition in the rehosted designer (and produce <Activity x:Class xaml) to either be compiled into a type, or to be executed by the dynamic activity, you would do WorkflowDesigner.Load(new ActivitySchemaType... ).
Let me know if that helps,
thanks,
matt
Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle- Marked as answer by AmyMacMicrosoft employee Monday, July 13, 2009 6:50 AM
Friday, July 10, 2009 4:13 PM
All replies
-
There can be an arguments button when rehosted, and there can be no arguments button when in VS. It ahs to do wtih what is the instance type that is being edited. If it is an ActivitySchemaType (which will compile into a type or be executed with DynamicActivity), then you will see the argument designer.
If it is simply an instance of an activity, like Flowchart or Sequence, there are no arguments to be edited.
Let me know if that helps!
matt
Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkleThursday, July 9, 2009 8:44 PM -
Could you please elaborate by what you mean by ActivitySchemaType? Maybe an example of such a type? I was under the impression that all activities were 'equal', .e.g. no special root activitiy (and therefore would have the same functionality). Thanks!Friday, July 10, 2009 12:31 AM
-
Certainly, and check out the blog post I put up here.
The WF Designer is an editor of instances, that is I must always edit an instance of a type. When one is creating a new activity, you are actually creating a new type (this is what we will refer to as the x:Class case, because the xaml looks like <Activity x:Class ). In order for our editor to work, we actually can't edit an instance of that new type, because you are creating and configuring a type, not an instance of a type. So we have ActivitySchemaType which serves as an instance of a type description, and that is what you edit.
Now, if you are rehosting, and you decide you want to do WorkflowDesigner.Load(new Sequence... ) you are simply editing an instance of the Sequence type, and in that case, you can't add arguments, you are just configuring a sequence, and indeed, the xaml for that would look like
<Sequence>
<Persist />
<WriteLine Text="[DateTime.Now]" />
....
However, if you want to edit a type definition in the rehosted designer (and produce <Activity x:Class xaml) to either be compiled into a type, or to be executed by the dynamic activity, you would do WorkflowDesigner.Load(new ActivitySchemaType... ).
Let me know if that helps,
thanks,
matt
Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle- Marked as answer by AmyMacMicrosoft employee Monday, July 13, 2009 6:50 AM
Friday, July 10, 2009 4:13 PM -
Thanks very much Matt - this does help! I didn't notice you had replied to my thread with the follow up answer until recently.
I tried what you suggested, but it didn't quite work immediately. However, by taking some points from your blog post, it wasn't too difficult to get it working. What I tried to do was to modify the designer rehosting sample code from the WF lab exercises. For example, I took completed first exercise code. I modified the AddDesigner method to look like this:
private void AddDesigner() { //Create an instance of WorkflowDesigner class this.wd = new WorkflowDesigner(); //Place the WorkflowDesigner in the middle column of the grid Grid.SetColumn(this.wd.View, 1); //Load a new Sequence as default. //this.wd.Load(new Sequence()); this.wd.Load(new ActivitySchemaType()); this.wd.Load(ast); //Add the WorkflowDesigner to the grid grid1.Children.Add(this.wd.View); }
This is what I understood your suggestion to be. However, when I ran the code, it threw an exception. After reviewing the blog post, I made a few changes and ended up with this:
private void AddDesigner() { //Create an instance of WorkflowDesigner class this.wd = new WorkflowDesigner(); //Place the WorkflowDesigner in the middle column of the grid Grid.SetColumn(this.wd.View, 1); //Load a new Sequence as default. //this.wd.Load(new Sequence()); ActivitySchemaType ast = new ActivitySchemaType() { Name = "workflowDesigner", Body = new Sequence { Activities = { } } }; this.wd.Load(ast); //Add the WorkflowDesigner to the grid grid1.Children.Add(this.wd.View); }
This modified version of the code worked without throwing any exceptions and the variables and arguments buttons are now both present.
Thanks,
NotreMonday, July 27, 2009 9:50 PM