I am using Window.ShowDialog()
to open a modal window in my WPF (MVVM) application, but it lets me navigate to other windows using the Windows taskbar (Windows 7).
Consider this: I have 3 non-modal windows open in my application. Now One of these opens a modal window using Window.ShowDialog()
. I also set Application.MainWindow
as the owner of the modal window. This is so because I am using MVVM messaging and the message handler to open a new window is centralized in App.xaml.cs
. The window does opens modally - no issues there. However, Windows 7 allows me to swtich to the other application windows from the taskbar. This leads to a situation where the modal window goes behind another window, which I prefer not to have.
I can't do anything on other windows as long as I have the modal open, but it would be nice if the modal window always remained on top as long as it's open. Is there a way I can disable taskbar switching when the modal is open? FYI - all open windows launched from the app appear as separate entries on the taskbar.
Thanks in advance!
A modal window creates a mode that disables the main window but keeps it visible, with the modal window as a child window in front of it. Users must interact with the modal window before they can return to the parent application. This avoids interrupting the workflow on the main window.
Dialog (dialogue): A conversation between two people. In a user interface, a dialog is a “conversation” between the system and the user. Mode: A special state of the system in which the same system has somewhat different user interfaces.
Definition: A modal dialog is a dialog that appears on top of the main content and moves the system into a special mode requiring user interaction. This dialog disables the main content until the user explicitly interacts with the modal dialog.
There isn't any code to base this off of, but it sounds like you have left off some properties on the Window
you've created and expected ShowDialog
to apply additional "dialog" semantics:
Window window = new Window() { Title = "Modal Dialog", ShowInTaskbar = false, // don't show the dialog on the taskbar Topmost = true, // ensure we're Always On Top ResizeMode = ResizeMode.NoResize, // remove excess caption bar buttons Owner = Application.Current.MainWindow, }; window.ShowDialog();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With