I am working on a WPF application where multiple windows can be present at one time. The Windows are shown using the Dispatcher and thus each Window has its own UI Thread, according to the WPF Threading Model https://msdn.microsoft.com/en-us/library/ms741870(v=vs.100).aspx . The below code is from this link.
private void ThreadStartingPoint()
{
Window1 tempWindow = new Window1();
tempWindow.Show();
System.Windows.Threading.Dispatcher.Run();
}
"This method is the starting point for the new thread. We create a new window under the control of this thread. WPF automatically creates a new Dispatcher to manage the new thread."
Is it possible to show a Window using ShowDialog(), that will be modal across all the Windows in my application? Meaning that a user would not be able to interact with any of the Windows while the dialog is shown.
My thought is that this is not possible since the Window can only be shown on one UI Thread and the other Windows will still be able to interact.
One solution I attempted is to set the owner to the MainWindow of the app. This throws an InvalidOperationException. "The calling thread cannot access this object because a different thread owns it."
DialogWindow dialog = new DialogWindow();
dialog.Owner = App.Current.MainWindow;
dialog.ShowDialog();
System.Windows.Threading.Dispatcher.Run();