Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Windows Workflow Foundation - Hosting the Designer (Part 2)

Blogs

Mike Taulty's Blog

Elsewhere

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

Comments

Mike Taulty's Blog wrote Windows Workflow Foundation - Hosting the Designer Part 2.5
on Tue, Aug 22 2006 6:28 AM
Following on from this previous post&amp;nbsp;a tip that I'd pass on about hosting the designer.  I've been...
Mike Taulty's Blog wrote Windows Workflow Designer Hosting - Part 3 (Fixing some stuff from Part 2)
on Tue, Aug 22 2006 7:21 AM
Back in part 2&amp;nbsp;I'd basically managed to get something from the Workflow Designer on the screen and...
Mike Taulty's Blog wrote Workflow Designer Hosting - Summing Up (for now)
on Wed, Sep 6 2006 9:53 AM
I've been playing with the Workflow designer hosting for a little while, trying to get my head around...
Wilm’s FuzzyLogic » Blog Archive » New Windows Workflow Foundation Links wrote Wilm&#8217;s FuzzyLogic &raquo; Blog Archive &raquo; New Windows Workflow Foundation Links
on Wed, Feb 14 2007 4:49 AM