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,
The way you describe is indeed exactly how it works now.
The problem is that in the XML file you have a class type RootDocument (so not my custom class derived from LayoutDocument).
If you de-serialize the RootDocument from the XML file you won't get my derived class back because that class type isn't specified in the XML file. You will get a LayoutDocument (base class), and not my custom derived class.