Skip to main content
A newer version of this page is available. .

Saving and Restoring Layout Basics

  • 2 minutes to read

DevExpress WPF controls (e.g., DXGrid, DXPivotGrid, DXDocking, DXBars and DXLayoutControl) allow you to save layout information to an XML file or a stream. Once saved, the control’s layout can be restored when required. Layout information may include the visibility, position and size of visual elements in a control, their appearance settings, filter, sorting, grouping and summary information, etc. Individual controls provide options allowing you to control which settings should be saved. To learn more, see the Layout Options topic.

You can save and restore the layout of controls using one of the following approaches.

  1. To save the layout of all visual serializable DevExpress controls that are nested within a single object (e.g., a window or a BarManager), use the DevExpress.Xpf.Core.Serialization.DXSerializer.Serialize and DevExpress.Xpf.Core.Serialization.DXSerializer.Deserialize methods.


    To enable the layout of visual serializable DevExpress controls to be saved and restored via the DXSerializer class functionality, set the DevExpress.Xpf.Core.Serialization.DXSerializer.DXSerializer.SerializationID attached property for the controls to unique objects (e.g., unique strings).

    The Serialize method saves the layout of the visual DevExpress controls to a single file.


    The layouts of controls that are not in the Visual Tree are not saved by the DXSerializer class.

  2. To save/restore the layout of an individual DevExpress control, use the control’s SaveLayoutTo… and RestoreLayoutFrom… methods.

    For example, DXGrid provides the DataControlBase.SaveLayoutToStream, DataControlBase.SaveLayoutToXml, DataControlBase.RestoreLayoutFromStream and DataControlBase.RestoreLayoutFromXml methods.

    When using this approach, the layouts of multiple controls cannot be saved to a single file. Each layout must be stored in a separate file.

To save the control layout when a window is about to close, handle the Window.Closing event. To restore the layout when a window is being loaded, handle the Window.Loaded event.


The following code shows how to save and restore the layout of serializable DevExpress controls via members of the DevExpress.Xpf.Core.Serialization.DXSerializer class:

<Window . . .

    <!--Set SerializationID for DevExpress serializable objects-->
    <dxb:BarManager dx:DXSerializer.SerializationID="myBarManager">
    . . . 
        <dxg:GridControl dx:DXSerializer.SerializationID="myGrid">
        . . .