Frame.SaveModel() Method
Writes information on a Frame‘s View and Template to the Application Model.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Remarks
This method writes the current settings of the current Frame‘s Frame.View and Frame.Template (e.g. the settings of a Detail View’s items or a List View’s Grid Editor) to the corresponding Application Model nodes. Currently, this method is used in Windows Forms Applications when closing a Window. In ASP.NET Web Forms applications, end-users cannot customize UI elements.
Generally, you do not need to call this method. You can handle the Frame.ViewModelSaving and Frame.TemplateModelSaving events which are raised when synchronising information on the Frame’s View and Template, respectively.
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();
}
// ...
}