expressappframework-devexpress-dot-expressapp-dot-xafapplication-77633a1a.md
Saves the changes made by an end-user, up to the current moment, to the differences storage.
Namespace : DevExpress.ExpressApp
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
public virtual void SaveModelChanges()
Public Overridable Sub SaveModelChanges
XAF calls this method when it needs to save user settings. You can call it at any time during the application run. For example, you can implement an Action that allows users to save the changes.
You can save user changes to another storage; for example, to the database. For this purpose, handle the XafApplication.CreateCustomUserModelDifferenceStore event.
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();
}
// ...
}
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SaveModelChanges() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
UpdateUserViewVariantsAction(); //Updates the items of our User View Variant Action based on the current the Change Variant Action structure.
Application.SaveModelChanges();
var cnt = Frame.GetController<ShowNavigationItemController>();
See Also