Following on from this post and always with reference to this article...

I've moved along in Workflow versions in that I'm now working on Vista RC1 with the RC of .NET Framework V3.0 on it - it didn't seem to cause any noticeable changes for me in the Workflow area yet but I've only been looking at it for maybe 20 minutes so there's a lot of time yet :-)

I thought I'd have a go at adding a Save menu option to my existing sample code and, in the first case, see if I can get my XAMl/XOML saved for my Workflow definition as, so far, I've done nothing in these posts about code-files or rules-files or anything like that so I've only got XAML/XOML to save.

This one doesn't seem too difficult. I've already got a class that derives from WorkflowDesignerLoader and I can go ahead and override the PerformFlush method on it with something like;

 
    protected override void PerformFlush(IDesignerSerializationManager 
      serializationManager)
    {
      IDesignerHost host = this.GetService(typeof(IDesignerHost)) as
        IDesignerHost;

      Activity rootActivity = host.RootComponent as Activity;

      WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();

      using (XmlWriter xmlWriter = XmlWriter.Create(workflowFileName))
      {
        serializer.Serialize(serializationManager, xmlWriter, rootActivity);
      }
    }
 

and that seems to provide me with the basics of getting the XAML/XOML serialized back into my file. The only other thing I have to add somewhere is a menu item that asks for the Workflow definition to be saved;

    private void saveToolStripMenuItem_Click(object sender, EventArgs e)
    {
      WorkflowDesignerLoader loader = GetHostService<WorkflowDesignerLoader>();

      loader.Flush();
    }
 

and that seems to do the trick in as much as saving off XAMl/XOML for the Workflow definition.

If you want the project file in the state that it's reached for this post then it's here.