[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]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Collapse]Layout Management
   [Expand]Dock Windows
   [Collapse]Tile and Layout
    [Expand]Layout and Data Layout Controls
     Tile Layout Control
     Dock Layout Control
     Flow Layout Control
    [Collapse]Common Features
      Save and Restore Item Layout
    [Expand]Examples
   [Expand]Tab Control
   [Expand]Carousel
    Book Control
    Workspace Manager
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [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)

Save and Restore Item Layout

Controls included in the Xpf.LayoutControl library provide methods to dynamically save and restore their item layouts to (from) streams or local storage.

Expanded Layout and Data Layout Control

Control layouts within a Layout Control can be saved to a data store and restored at a later time. This comes in handy when you allow your end-users to customize a layout in Customization Mode.

To save a layout to a data store, use LayoutControl's LayoutControlBase.WriteToXML inherited method. The LayoutControl.ReadFromXML method restores a 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.

When saving/loading layouts to a data store, only properties that can be changed by an end-user during layout customization are stored/restored.

If you need to save/load custom properties when a layout is saved/loaded, handle the LayoutControl.WriteElementToXML and LayoutControl.ReadElementFromXML events.

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.

Note

Controls added dynamically to a Layout Control should be registered via the RegisterName method to save/restore their layout correctly.

Expanded Other Controls

Other controls provided by the Xpf.LayoutControl library aslo deriver from the LayoutControlBase class and thus, can dynamically save and restore their layouts by calling the LayoutControlBase.WriteToXML and LayoutControlBase.ReadFromXML methods.

The number of settings that can be saved is limited. Typically, you can only save and restore item sizes and their orders. Global control properties (e.g, the Flow Layout Control's orientation or its splitters' visibility) is not saved.

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