Reputation: 163
I am new to C# and WPF. I want to open a new window and remain totally in that window locking the parent i.e. something similar to MessageBox
I have a menu item that I choose calls a method OnClose, I then create and show my confirm close window. I disable the parent but it runs through the entire method I want to wait until the second windows I created has closed.
void OnClose(object sender, ExecutedRoutedEventArgs args)
{
//this.IsEnabled = true;
ConfirmClose cc = new ConfirmClose();
this.IsEnabled = false;
cc.Show();
cc.Focus();
// How can I wait here until the windows cc has closed
this.IsEnabled = true;
}
Upvotes: 2
Views: 573
Reputation: 79979
Instead of .Show()
use .ShowDialog()
, then the user can't return to the parent window unless he close the form, like this:
ConfirmClose cc = new ConfirmClose();
cc.ShowDialog();
Assuming that ConfirmClose
is a System.Windows
.
Upvotes: 10