Close strategy not executed

Topics: UI Architecture
Apr 2, 2012 at 1:05 PM


I am developing an application with a tabcontrol, the shell will host this tabcontrol where workspaces will be shown. Now I have implemented the close strategy from the HelloScreens sample, this works fine when I close the whole application. But I also added a close button to my tab header so the user can close indivual tabs. When the button is clicked the code below is executed in my shellviewmodel:

        public void CloseWorkspace()
            if (!CanCloseWorkspace)



The problem is that the TryClose will not call my Close strategy method, but when I close the whole application it works fine?

        protected virtual void DoCloseCheck(IDialogManager dialogs, Action<bool> callback)
            Contracts.Services.Dialog.MessageBoxOptions selection = Dialogs.ShowMessageBox(
                "There is unsaved data, do you want to close?",
                "Unsaved Data",
                box => callback(box.WasSelected(Contracts.Services.Dialog.MessageBoxOptions.Yes))

            if (selection == Contracts.Services.Dialog.MessageBoxOptions.Yes)
                this.IsDirty = false;

        public override void CanClose(Action<bool> callback)
            if (IsDirty)
                DoCloseCheck(Dialogs, callback);

Could somebody give me some hints?

All my workspaces implement Screen and the IWorkspace interface and the ShellViewModel implements Conductor<IWorkspace>.Collection.OneActive.

Thanks in advance,