Saving and loading of the layout is possible with custom LayoutDocuments (class derived from LayoutDocument) as long as they are docked in the LayoutDocumentPane. But if a LayoutDocument is dragged onto an other screen, the custom LayoutDocument is stored in a LayoutDocumentFloatingWindow.
If now the custom LayoutDocument is saved/loaded the custom type isn't stored in the XML file. The XML file contains a RootDocument instead of the custom derived class name.
Therefore saving/load a CUSTOM LayoutDocument in a LayoutDocumentFloatingWindow is not possible.
To solve this, I made a proposal for serializing LayoutDocumentFloatingWindow, LayoutFloatingWindow and LayoutAnchorableFloatingWindow. Serialization is performed by implementing the IXmlSerializable interface.
The nasty thing was that in the layout XML file I wanted the following structure:
<FloatingWindows>
<LayoutDocumentFloatingWindow>
<CustomLayoutDocument1 />
<LayoutDocumentFloatingWindow />
<LayoutDocumentFloatingWindow>
<CustomLayoutDocument2 />
<LayoutDocumentFloatingWindow />
<FloatingWindows />
Therefore I had to implement the IXmlSerializable in LayoutRoot.
See attached files with the solutions and an example of the resulting XML file.
Comments: ** Comment from web user: EricBakx **
If now the custom LayoutDocument is saved/loaded the custom type isn't stored in the XML file. The XML file contains a RootDocument instead of the custom derived class name.
Therefore saving/load a CUSTOM LayoutDocument in a LayoutDocumentFloatingWindow is not possible.
To solve this, I made a proposal for serializing LayoutDocumentFloatingWindow, LayoutFloatingWindow and LayoutAnchorableFloatingWindow. Serialization is performed by implementing the IXmlSerializable interface.
The nasty thing was that in the layout XML file I wanted the following structure:
<FloatingWindows>
<LayoutDocumentFloatingWindow>
<CustomLayoutDocument1 />
<LayoutDocumentFloatingWindow />
<LayoutDocumentFloatingWindow>
<CustomLayoutDocument2 />
<LayoutDocumentFloatingWindow />
<FloatingWindows />
Therefore I had to implement the IXmlSerializable in LayoutRoot.
See attached files with the solutions and an example of the resulting XML file.
Comments: ** Comment from web user: EricBakx **
Hi BoucherS,
I tested your suggestion with my code, and now it works fine.
You were right, I was missing that part of the solution.
With this solution I can now save the layout of my custom LayoutDocument in a LayoutDocumentFloatingWindow.
Are you planning to integrate my proposal into AvalonDock?
In which version can I expect it?
Thanks for your help!