Search code examples
wpfwindowsdialogtaskbar

Disallow "Background" Window from Being Active WPF


This one is a little hard to explain, it has more to do with .NET and the Windows operating system than WPF, but I have a WPF app that has a "MainWindow" and in this window there is a menu such as File, Edit, etc. If a user clicks on one of these menu items, a dialog window will appear via the ShowDialog() method. This works as I expect it to, but I've had the request to make it so that the user cannot select the inactive window at all. The user currently can by going to the taskbar and selecting the inactive window, this will then bring the inactive window to the forefront. The user won't be able to do anything, but it is on top of the window that should be active. Is this even possible to correct?

Thanks!


Solution

  • @J.H. had the idea I needed.

    Essentially, I did:

    Application.Current.MainWindow.ShowInTaskbar = false;

    Works like a charm (made sure to set ShowInTaskbar back to true when the dialog window closes)