What happened
In versions prior to v19.2, the save confirmation dialog is shown each time you close DetailView even if you don't make any changes. This might confuse end users, because no user data needed to be saved in this case.
In v19.2, we disabled the confirmation dialog for a new unmodified object - an XAF WinForms app now behaves as Microsoft Outlook. This already worked correctly in XAF ASP.NET WebForms apps.
How to restore the previous behavior
In XAF v19.2 WinForms apps, set the WinModificationsController.ConfirmCloseUnchangedNewObject property to True as described at Customize Controllers and Actions:
C#using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win.SystemModule;
namespace YourSolutionName.Module.Win.Controllers {
public class EnableConfirmationViewController : ViewController<DetailView> {
protected override void OnActivated() {
base.OnActivated();
WinModificationsController winModificationsController = Frame.GetController<WinModificationsController>();
if(winModificationsController != null) {
winModificationsController.ConfirmCloseUnchangedNewObject = true;
}
}
}
}
Visual BasicImports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Win.SystemModule
Namespace YourSolutionName.Module.Win.Controllers
Public Class EnableConfirmationViewController
Inherits ViewController(Of DetailView)
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
Dim winModificationsController As WinModificationsController = Frame.GetController(Of WinModificationsController)()
If winModificationsController IsNot Nothing Then
winModificationsController.ConfirmCloseUnchangedNewObject = True
End If
End Sub
End Class
End Namespace
How to enable the new behavior in v19.1.5+
If you want to test the new behavior prior to v19.2, add the aforementioned Controller, but set the WinModificationsController.ConfirmCloseUnchangedNewObject property to False.
Business model & logic considerations if you initialize new objects from code
1. If you want to show the confirmation dialog, raise change notifications from property setters as described at PropertyChanged Event in Business Classes. Below is the XPO example:
C#using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
public class DemoTask : Task {
//...
private Priority priority;
public Priority Priority {
get { return priority; }
set { SetPropertyValue(nameof(Priority), ref priority, value); } //!!!
}
}
//...
namespace YourSolutionName.Module.Controllers {
public class InitializePriorityViewController : ViewController<DetailView> {
public InitializePriorityViewController() {
SimpleAction setPriorityAction = new SimpleAction(this, "SetPriority", PredefinedCategory.Edit);
setPriorityAction.Execute += (sender, e) => {
DemoTask demoTask = (DemoTask)View.CurrentObject;
demoTask.Priority = Priority.High;
};
}
}
}
Visual BasicImports DevExpress.ExpressApp
Imports DevExpress.Persistent.BaseImpl
Public Class DemoTask
Inherits Task
'...
Private _priority As Priority
Public Property Priority() As Priority
Get
Return _priority
End Get
Set(ByVal value As Priority)
SetPropertyValue(NameOf(Priority), _priority, value) '!!!
End Set
End Property
End Class
'...
Namespace YourSolutionName.Module.Controllers
Public Class InitializePriorityViewController
Inherits ViewController(Of DetailView)
Public Sub New()
Dim setPriorityAction As New SimpleAction(Me, "SetPriority", PredefinedCategory.Edit)
AddHandler setPriorityAction.Execute, Sub(sender, e)
Dim demoTask As DemoTask = CType(View.CurrentObject, DemoTask)
demoTask.Priority = Priority.High
End Sub
End Sub
End Class
End Namespace
2. If you don't want to show the confirmation dialog, update the private field value directly as follows:
C#using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
public class DemoTask : Task {
//...
private Priority priority;
public void SetPriority(Priority priority) {
this.priority = priority;
}
}
//...
namespace YourSolutionName.Module.Controllers {
public class InitializePriorityViewController : ViewController<DetailView> {
public InitializePriorityViewController() {
SimpleAction setPriorityAction = new SimpleAction(this, "SetPriority", PredefinedCategory.Edit);
setPriorityAction.Execute += (sender, e) => {
DemoTask demoTask = (DemoTask)View.CurrentObject;
demoTask.SetPriority(Priority.High); //!!!
};
}
}
}
Visual BasicImports DevExpress.ExpressApp
Imports DevExpress.Persistent.BaseImpl
Public Class DemoTask
Inherits Task
'...
Private _priority As Priority
Public Sub SetPriority(ByVal priority As Priority)
Me._priority = priority
End Sub
End Class
Namespace YourSolutionName.Module.Controllers
Public Class InitializePriorityViewController
Inherits ViewController(Of DetailView)
Public Sub New()
Dim setPriorityAction As New SimpleAction(Me, "SetPriority", PredefinedCategory.Edit)
AddHandler setPriorityAction.Execute, Sub(sender, e)
Dim demoTask As DemoTask = CType(View.CurrentObject, DemoTask)
demoTask.SetPriority(Priority.High) '!!!
End Sub
End Sub
End Class
End Namespace
3. In v19.2, the IObjectSpace.ObjectChanged event is not raised in response to the editor's ControlValueChanged event.