IEditableObject in MVVM

Can you think of a scenario in which IEditableObject would still be useful in a MVVM-based WPF application? If yes, you have an example demonstrating this.

+7
wpf mvvm ieditableobject
source share
3 answers

I used IEditableObject in one of my applications. For example, if you have a dialog for editing something, you can implement IEditableObject on the ViewModel. BeginEdit() when the dialog box opens, EndEdit() when the user clicks the OK button and CancelEdit() when the user clicks the Cancel button.

IEditableObject is a good interface anytime you want to roll back changes.

+14
source share

Inside the type displayed in the DataGrid . This was necessary, because when I use tabs, and the DataGrid is stored on this tab, the tabs necessary for forcing to speak within the DataGrid switch if the cell was active; discarding changes because they were not committed. T

To achieve this function, DataGrid behavior is applied, but part of IEditableObject is below.

 private IDatabaseConnection _copy; void IEditableObject.BeginEdit() { if (this._copy == null) this._copy = _container.Resolve<IDatabaseConnection>(); _copy.Database = this.Database; _copy.DisplayName = this.DisplayName; _copy.HostName = this.HostName; _copy.Username = this.Username; _copy.Password = this.Password; } void IEditableObject.CancelEdit() { this.Database = _copy.Database; this.DisplayName = _copy.DisplayName; this.HostName = _copy.HostName; this.Username = _copy.Username; this.Password = _copy.Password; } void IEditableObject.EndEdit() { _copy.Database = String.Empty; _copy.DisplayName = String.Empty; _copy.HostName = String.Empty; _copy.Username = String.Empty; _copy.Password = String.Empty; } 
+2
source share

I have an IEditableObject implementation in my application, so that I can not update my data model if the user entered is invalid, and roll back to the original values ​​if the user refused the changes.

+2
source share

All Articles