Skip to main content

LayoutControl.ReadFromXML(XmlReader) Method

Restores the layout of child items that have been previously saved via the LayoutControlBase.WriteToXML method. The method optimizes the layout after loading (removes empty and unnecessary groups) without visually breaking the layout.

Namespace: DevExpress.Xpf.LayoutControl

Assembly: DevExpress.Xpf.LayoutControl.v24.1.dll

NuGet Package: DevExpress.Wpf.LayoutControl

Declaration

public override void ReadFromXML(
    XmlReader xml
)

Parameters

Name Type Description
xml XmlReader

An XmlReader object from which data is read.

Remarks

You can save the layout of child items via the LayoutControlBase.WriteToXML method. The ReadFromXML method allows you to load the previously saved layout.

Note

To correctly save and then restore the layout of items, you need to assign names to the items. If names are not specified, the layout will be correctly restored, provided that the LayoutControl’s/LayoutGroup’s item collection (the order and number of items) wasn’t modified after the layout was saved.

To load a layout, we recommend using the Loaded event of a UserControl or a window.

Example

The following example shows how to save the layout of items of a LayoutControl object to a stream, and then restore the layout. The LayoutControlBase.WriteToXML and LayoutControl.ReadFromXML methods are used to do this.

using System.Xml;
using System.IO;

MemoryStream stream = new MemoryStream();

//Save the layout
XmlWriter writer = XmlWriter.Create(stream);
myLayoutControl.WriteToXML(writer);
writer.Close();

//Load the layout
stream.Seek(0, SeekOrigin.Begin);
XmlReader reader = XmlReader.Create(stream);
myLayoutControl.ReadFromXML(reader);
reader.Close();
See Also