I will play around with activation and see.
An interesting note that I forgot to mention - this only happens when there is a dialog box displayed over the detail screen. The user opens the detail screen from the main view model and when they close it my dirty checking logic runs and if the detail screen is dirty a standard Yes/No/Cancel dialog box appears. If the user presses Yes Or No, I invoke callback(true) and that is when the detail screen disappears and the main view model loses focus and goes to the background. If I minimize all my other applications, it is still there - but behind everything. If the form is not dirty, no dialog is displayed and callback(true) is invoked without any other code and in that case, the main view model does not go to the background and everything works as expected. It's bizarre. :) Oddly enough, I had a similar problem once in WinForms.
publicoverridevoid CanClose(Action<bool> callback) { if (!Security.IsDirty) { callback(true); return; } var dialogResult = MessageBox.Show("Do you wish to save your changes?", "Unsaved Changes", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); switch(dialogResult) { case MessageBoxResult.Yes: Save(); callback(true); break; case MessageBoxResult.No: callback(true); break; case MessageBoxResult.Cancel: callback(false); break; } }