[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Collapse]Common Concepts
  [Expand]Themes
  [Expand]Images
  [Expand]Printing and Exporting
  [Collapse]Saving and Restoring Layouts
    Saving and Restoring Layout Basics
    Layout Options
   Typed Styles
  [Expand]Touch Support
  [Expand]Expressions
   Filtering
  [Expand]Formatting Values
   Prism Adapters
  [Expand]Data Sources
  [Expand]Performance Improvement
   XAML Namespaces
 [Expand]MVVM Framework
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Saving and Restoring Layout Basics

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.

    Note

    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.

    Note

    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.

Expanded Example

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:

Is this topic helpful?​​​​​​​