Saving WF Designer layout information


So you created a fancy new application and it hosts the WF designer. It's all looking good and when you go to load up that cool state machine workflow you created earlier to add a bit more polish, you notice that all the layout you worked for hours (ok, maybe not that long) is gone. You know need to add the ability to load and save layout information for the workflow definitions your application creates. Note that you'll still need a way to associate specific layout information to a specific workflow, but I'll leave that as an exercise for you since there's about 5001 different ways). So, to save layout information for a workflow within a hosted designer, use the following code from your WorkflowDesignerLoader class:

public void SaveLayout()

{

    using (XmlWriter writer = XmlWriter.Create("wfInstanceId.designer.xml"))  

    {

        IList layoutSaveErrors = new ArrayList() as IList;

        IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

        ActivityDesigner rootDesigner =

            host.GetDesigner(host.RootComponent) as ActivityDesigner;

        this.SaveDesignerLayout(writer, rootDesigner, out layoutSaveErrors);

    }

}

Skip to main content