The cliffhanger of the previous post was that I'd managed to get a simple Workflow definition to load from a XAML file and show up in the designer without too much code but I'd yet to make it do anything at all other than display the Workflow.
Taking this one step further, I want to add a property grid to my form so that I can display the properties (or at least some of them) of the selected Activity. The form now looks like;
I added a SplitContainer and a PropertyGrid to the form.
Then, the selections that are made in the designer need to show up in the PropertyGrid so I added a little method to make the grabbing of services easier from the DesignerHost;
private T GetHostService<T>() where T : class
{ T service = designerHost.GetService(typeof(T)) as T;
return (service);
}
And then at the point where the Form loads, we add an event handler for the SelectionChanged event and that's used to update the property grid to show the right object (s);
private void InitialiseSelectionChangedHandler()
{ ISelectionService selectionService =
GetHostService<ISelectionService>();
selectionService.SelectionChanged +=
new EventHandler(OnSelectionChanged);
}
void OnSelectionChanged(object sender, EventArgs e)
{ ISelectionService selectionService =
GetHostService<ISelectionService>();
propertyGrid1.SelectedObjects =
(object[])selectionService.GetSelectedComponents();
}
And there's also a little piece of code to select the root Activity when the Workflow definition is first loaded;
private void SelectRootActivity()
{ ISelectionService selectionService =
GetHostService<ISelectionService>();
selectionService.SetSelectedComponents(
new object[] { designerHost.RootComponent }); }
and that gets some basic selection and property display onto the screen. The property grid isn't quite as functional as it could be in that it doesn't display the dialog for editing conditions (code or declarative and I'm staying away from code for now) and there's a bunch of other things it doesn't do but it's on the screen! :-)
The project at this point is here. Designer Part 3.
Posted
Mon, Aug 21 2006 2:02 AM
by
mtaulty