In the Feature Browser, the sample for SaveLayout and LoadLayout works for panes that are created statically in the xaml. Do you have an example of Save(and Load)Layout when the user has dynamically loaded documents and moved them around?
If no example, do you have any advice to help me extend these methods to perhaps save the Type of the class contained in the SplitPane, then load that Type before setting the docking position of the contentpane? After working with these methods over the weekend, I see that the xml generated by the SaveLayout method identifies the contentpane by its Name. But the LoadLayout method does not actually create the instance of this object if it does not exist in the xaml. That's what I need to do.
Thanks in advance for any guidance you can provide.
During the LoadLayout, if a ContentPane with a Name that is not currently part of the XamDockManager is encountered, the InitializePaneContent event is raised. The event argument has a new ContentPane whose Name and SerializationId have been initialized with the information stored in the layout. You would then handle this event and use the information you put in the SerializationId before the layout was saved to determine what type of element to construct, create an instance of that and set the Content of the e.NewPane (as well as any other properties on the pane - e.g. Header). If the e.NewPane.Content is not set, then the pane is not included in the layout being loaded. So you need to make sure that you set the SerializationId to a string that contains the information you need to know what type of element to create.
Excellent! Thank you for the quick reply! I will give that a try.
At the point at which the event is fired, nothing has been put into the splitpanes, tabgrouppanes, etc. so you cannot do that at that point. In theory you could leave that pane in there and then remove it after the load but if there were any ContentPanePlaceholders created for the old positions of the pane it will reference the pane we created during the load. You should submit the issue to the support group.
Thanks again for your assistance. We're almost there...
I am able to save the various class types that I need in the SerializationID of the ContentPane. (I am saving two class types: a class type derived from ContentPane and a type of Page that is shown in a Frame within the ContentPane)
However, when I handle the InitializePaneContent event, setting the content of the NewPane will not achieve what I am looking for. I am trying to show an instance of a class derived from ContentPane (which we call BaseDockableContent in our project). The code behind the class is certainly required for the pane to function. I can't just copy its content to the NewPane and NewPane is read-only, so I can't replace it with my class instance.
Is there a way to get a reference to the SplitPane that is targeted by NewPane? Then allow the NewPane to be destroyed, but add my new instance of BaseDockablePane to the target SplitPane of the XamDockManager?
Thanks again for your assistance.