Back to Devexpress

How to: Save and restore layout of items in LayoutControl

wpf-8364-controls-and-libraries-layout-management-tile-and-layout-examples-how-to-save-and-restore-layout-of-items-in-layoutcontrol.md

latest923 B
Original Source

How to: Save and restore layout of items in LayoutControl

  • Jun 07, 2019

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.

csharp
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();