|
Hello,
I have a question about the CloseStrategy. I have used the code from the HelloScreens example. This works great when closing indivual screens, but when I close the whole application and there are still screens with dirty data, the application closes whithout
any warning. But I want to show warnings for every screen which contains dirty data, such that the user can cancel the closing.
I have used the ApplicationCloseStrategy and ApplicationClosCheck classes from the example.
I have a shellviewmodel with a conductor which conducts IWorkspace instances, none of these IWorkspace instances implement a Conductor. I haven't overriden the CanClose in my shellviewmodel, do I need to override this function in my shellviewmodel?
The shellviewmodel signature is:
[Export(typeof(IShell))]
public class ShellViewModel : Conductor<IWorkspace>.Collection.OneActive, IShell
The IWorkspace instances have the following signature:
[Export(typeof(CustomerViewModel))]
[ExportWorkspace(WorkspaceType = WorkspaceTypes.CustomerViewModel)]
[PartCreationPolicy(CreationPolicy.NonShared)]
public class CustomerViewModel : WorkspaceBase<Customer>, IWorkspace
The WorkspaceBase class contains the close logic, such that all the IWorkspace instances will inherit that.
public abstract class WorkspaceBase<T> : ValidationBaseSingleEntity, IHaveShutdownTask
where T : EntityObject, IEntity
{
public IResult GetShutdownTask()
{
return IsDirty ? new ApplicationCloseCheck(this, DoCloseCheck) : null;
}
protected virtual void DoCloseCheck(IDialogManager dialogs, Action<bool> callback)
{
Dialogs.ShowMessageBox(
"The screen has unsaved data!",
MessageBoxKind.Warning,
"Unsaved Data",
MessageBoxOptions.YesNo,
box => callback(box.WasSelected(MessageBoxOptions.Yes))
);
}
public override void CanClose(Action<bool> callback)
{
if (IsDirty)
DoCloseCheck(Dialogs, callback);
else
callback(true);
}
// More code
}
What am I doing wrong here?
Marcel
|