Skip to content

Handles the DXSerializer.LayoutUpgrade event to modify or update previously saved layouts when the app's layout structure changes across versions.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/wpf-dock-layout-manager-upgrade-layouts-between-versions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WPF Dock Layout Manager – Upgrade the Application Layout Between Versions

When you change the application layout (for example, adding new panels, enabling MDI mode, or rearranging groups) previously saved layouts may become outdated or incompatible. This example saves and restores layouts while supporting structural changes across different versions of the application.

Use this example to:

  • Detect the version of the layout being restored.
  • Apply upgrade logic to adjust the layout for both DockLayoutManager and nested controls like GridControl.
  • Preserve backward compatibility while keeping layouts aligned with the current application structure.

Upgrade the Application Layout Between Versions

Implementation Details

Version Management

The DXSerializer.LayoutVersion property specifies the version of the current layout. In this example, the ComboBoxEdit control allows the user to change the current layout version:

<dxe:ComboBoxEdit EditValue="{Binding ElementName=dockLayoutManager, Path=(dx:DXSerializer.LayoutVersion)}">
    <sys:String>1.0</sys:String>
    <sys:String>2.0</sys:String>
</dxe:ComboBoxEdit>

Save and Restore Layouts

Use the WorkspaceManager component to save the application layout to an XML file and restore it when needed:

manager.CaptureWorkspace("TestWorkspace");
manager.SaveWorkspace("TestWorkspace", layoutPath);
manager.LoadWorkspace("TestWorkspace", layoutPath);
manager.ApplyWorkspace("TestWorkspace");

Upgrade Logic

When a layout from an older version is restored, the GridControl and DockLayoutManager raise the DXSerializer.LayoutUpgrade event to apply custom upgrade logic and adapt the layout to the current version of the application.

  • For the DockLayoutManager, the handler switches the MDI style if the layout version is "1.0":
void OnDockLayoutManagerLayoutUpgrade(object sender, LayoutUpgradeEventArgs e) {
    if (e.RestoredVersion == "1.0") {
        documentGroup1.MDIStyle = MDIStyle.MDI;
    }
}
  • For the GridControl, the handler applies grouping based on the restored version:
void OnGridControlLayoutUpgrade(object sender, LayoutUpgradeEventArgs e) {
    if (e.RestoredVersion == "1.0") {
        ((GridControl)sender).GroupBy("Group");
    }
}

This logic ensures that older layouts can be upgraded to match the latest application structure and behavior.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Handles the DXSerializer.LayoutUpgrade event to modify or update previously saved layouts when the app's layout structure changes across versions.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 7