Skip to main content

Workspace Manager

  • 7 minutes to read

Many DevExpress controls provide methods to save their current layouts to a file, registry or stream, and then restore these layouts later on. These methods are sufficient when you need to manage a layout for one particular control. On the other hand, when your application contains multiple controls (toolbars, grid, navigation bar, etc.), saving/restoring the layout of each one of them manually becomes complicated. In such a case, the perfect solution would be to utilize any of the following components:

  • Workspace Manager (WorkspaceManager) - Allows you to manually save the layout information to a file or stream. Supports multiple layouts (workspaces) and animation effects.
  • Persistence Behavior (part of the Behavior Feature) - Automatically saves the layout information to a file or the system registry when the Form.FormClosed event fires and restores the saved layout when the Form.Load event fires.


We do not recommend saving layouts to the system registry because the amount of data can be too large. Save layouts to a file or stream instead.

The Workspace Manager detects all supported DevExpress controls within the target container (form, user control) and operates their layouts as one global application layout, called workspace. The list below enumerates major DevExpress controls supported by the Workspace Manager.

If you do not want to save the layout of a specific control, call the WorkspaceManager.SetSerializationEnabled method and pass the control as a parameter:

WorkspaceManager.SetSerializationEnabled(userControl, false);
foreach (Control control in userControl.Controls) {
    WorkspaceManager.SetSerializationEnabled(control, false);
    if(control is GridControl) {
        WorkspaceManager.SetSerializationEnabled((control as GridControl).MainView, false);

You can create multiple predefined application workspaces that your users will be able to choose from, as well as save and restore their own custom workspaces.

Getting Started (online video)


The manager uses four methods that operate workspaces.

As you may have noticed, all of these methods work with the WorkspaceManager.Workspaces collection - the place where all active workspaces are stored. Active workspaces are those that are ready to be applied. If a workspace is stored in a file but has not been loaded yet, it is considered inactive. To add predefined workspaces to your application as active workspaces, design them first, then save to XML files and load when the application starts, for instance on the FormLoad event.

private void Form1_Load(object sender, EventArgs e) {
    workspaceManager1.LoadWorkspace("Default", @"default.xml");
    workspaceManager1.LoadWorkspace("Compact", @"compact_layout.xml");
    workspaceManager1.LoadWorkspace("Detailed", @"full_layout.xml");

The manager searches for all supported controls within the object, assigned to its WorkspaceManager.TargetControl property.


The following code shows how to use the WorkspaceManager component to save the form’s bounds and state, and the layout of DevExpress controls when a form is closed, and load this layout when the form starts.

You may need to call the controls’ ForceInitialize methods (e.g., GridControl.ForceInitialize) before applying layouts to the controls in a Form.Load event handler.

 string file = "layout.xml";
 string workspaceName1 = "MyLayout";

 private void Form1_Load(object sender, EventArgs e) {
     //Use the WorkspaceManager to handle the layout of DevExpress controls that reside within the current form.
     workspaceManager1.TargetControl = this;

     // Save & restore the form's size, position and state along with DevExpress controls' layouts.
     workspaceManager1.SaveTargetControlSettings = true;

     // Disable layout load animation effects 
     workspaceManager1.AllowTransitionAnimation = DevExpress.Utils.DefaultBoolean.False;

    // Disable (de)serialization for the following controls (if required):
    //WorkspaceManager.SetSerializationEnabled(gaugeControl1, false);
    //WorkspaceManager.SetSerializationEnabled(accordionControl1, false);

    // When restoring layouts of controls in a Form.Load event handler,
    // you may need to call the controls' ForceInitialize methods to finish their initialization before restoring their layouts.

     //Load DevExpress controls' layouts from a file
     if (workspaceManager1.LoadWorkspace(workspaceName1, file, true))

 private void Form1_FormClosed(object sender, FormClosedEventArgs e) {
     //Save DevExpress controls' layouts to a file
     workspaceManager1.CaptureWorkspace(workspaceName1, true);
     workspaceManager1.SaveWorkspace(workspaceName1, file, true);

Bar Workspace Menu

To assist both you and your end-users in creating, saving and loading workspaces, the Workspace Manager provides a bar menu, represented by the BarWorkspaceMenuItem class. This item can be added to the required Bar or RibbonControl as the image below illustrates.

WSM - Bar Item

By default, this item only displays the active workspaces list and a button to capture the current workspace.

WSM - Default Menu

You can set the button’s ShowSaveLoadCommands property to true to display additional commands, which allow your end-users to save and load workspaces at runtime.

WSM - Full Menu

You can use this menu when developing the application to quickly design and save to files various layout versions. Afterwards you can set the ShowSaveLoadCommands property back to its default false value.

Switching between workspaces can be followed by animation effects. You can choose from eight animation types, available out-of-the-box, by selecting them from a control’s smart-tag. To do the same in code, create the required animation and assign it to the WorkspaceManager.TransitionType property.

DevExpress.Utils.Animation.PushTransition pushTransition1 = new DevExpress.Utils.Animation.PushTransition();
workspaceManager1.TransitionType = pushTransition1;


How to use WorkspaceManager to capture, apply, save and load workspaces

Prevent serialization / deserialization of a specific property

WorkspaceManager allows you to manage serialization/deserialization of properties in the PropertySerializing and PropertyDeserializing event handlers. Check the Component and PropertyName properties to identify what settings are being stored/restored and what controls they belong to. To prevent serialization / deserialization, set Cancel to true:

private void workspaceManager1_PropertyDeserializing(object sender, DevExpress.Utils.PropertyCancelEventArgs ea)
    GridView view = ea.Owner as GridView;
    if (view != null && view == gridView1)
            ea.Cancel = ea.PropertyName == "MultiSelect";
See Also