0

I am working on a WPF desktop application, which has screen-lock feature that shows the log-in dialog after application is inactive for some time. Everything works great until user walks away from the computer and there's modal dialog (other than the log-in dialog) opened in the app.

Quick summary of the scenario:

  1. User deletes something in the application.
  2. Delete confirmation (modal) dialog opens, with "Delete" and "Cancel" options.
  3. User walks away for a bit, while the modal dialog is up.
  4. After some time, the confirmation dialog will be hidden and the log-in dialog opens.

Here's a bit of the codes

var deleteConfirmationDialog = new deleteConfirmationDialog(deleteConfirmationViewModel);
var dialogResult = deleteConfirmationDialog.ShowDialog();
if (dialogResult ?? false) { //Delete item }

The issue is when the deleteConfirmationDialog is hidden, and the log-in (modal) dialog is opened, then the dialogResult from the deleteConfirmationDialog will return with dialogresult == false.

Technical implementation and philosophy aside, why does ShowDialog() returns with a DialogResult == false, even though I did not close that dialog? Is there away to prevent deleteConfirmationDialog from returning False?

Thank you very much in advance! Please let me know, if any part of this doesn't make sense.

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
Ming
  • 141
  • 9
  • How's that login dialog triggered and opened? – Andreas H. Apr 16 '14 at 20:51
  • `why does ShowDialog() returns with a DialogResult == false` -- you tell us. The `deleteConfirmationDialog` is your class. – McGarnagle Apr 16 '14 at 21:19
  • Thanks for the reply Andreas. The login dialog is triggered with MVVM Light Messenger, where it passes the View Model to the MainWindow.xaml.cs. There's a timer running in the background that keeps track of the user inputs to the application. When application is idle after X minutes, it'll call the Messenger.Default.Send(LoginViewModel), and MainWindow.xaml.cs registers for that message and generate a new login dialog. – Ming Apr 17 '14 at 01:10
  • In addition, when the idle timer elapses, it'll also call the Messenger.Default.Send(HideDeleteConfirmationDialog). Hope this helps. Thanks again! – Ming Apr 17 '14 at 01:21
  • Hi McGarnagle, thanks for the reply. Even though, I own those two windows, but I am not familiar with the Window control's life cycle. Somehow, when I do var dialogResult = DeleteConfirmationDialog.ShowDialog() and then when I call DeleteConfirmationDialog.Hide() from another thread, dialogResult will be set to False. Why does calling Window.Hide() triggers ShowDialog() to return with False? Is there a way to prevent that from happening? Thanks again! – Ming Apr 17 '14 at 01:28

0 Answers0