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: BoucherS **
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: BoucherS **
Hi,
using Toolkit v2.9 with a small sample, I was able to serialize a custom LayoutDocument which is floating.
You can find the sample in attachment (WpfApplication118.zip). Simply add a reference to Xceed.Wpf.AvalonDock.dll.
The resulting file : SavedFile.xml contains a LayoutFloatingWindow with a RootDocument (its content property).
If I move the LayoutDocuments and LayoutAnchorables around and then load the saved file, the FloatingWindow is restored with its custom LayoutDocument.