Skip to main content

Frame.SaveModel() Method

Writes information about the Frame‘s View and Template to the Application Model.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v25.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public void SaveModel()

Remarks

This method writes the current settings of the Frame‘s View and Template to the corresponding Application Model nodes. For example, it saves layout settings in Detail Views and List Editor settings in List Views. The system calls this method automatically when a window closes.

You usually do not need to call this method. You can handle the Frame.ViewModelSaving and Frame.ViewModelSaving events. The system raises these events when it synchronizes information on the frame’s view and template.

Example

The code below saves the current application state:

File:
MySolution.Win/Controllers/MyController.cs

using DevExpress.ExpressApp.Win;
// ...
public class MyController : ViewController { //or WindowController
// ...
    private void action_Execute(object sender, SimpleActionExecuteEventArgs e) {
        // Save Model settings in all opened windows in a WinForms application.
        foreach(Frame frame in ((WinShowViewStrategyBase)Application.ShowViewStrategy).Windows) {
            frame.SaveModel();
            // OR
            // frame.View.SaveModel();
        }

        // OR
        // Save Model settings only in the main application window.
        // Application.MainWindow.SaveModel();

        // Save the latest Model settings to a Model difference storage.
        Application.SaveModelChanges();
    }
// ...
}
See Also