In WPF, how do I darken all screen area when opening a new window?
Also after the window is closed, how do I revert the temporary effect?
You may create a background transparent window like this:
var darkwindow = new Window() {
Background = Brushes.Black,
Opacity = 0.4,
AllowsTransparency = true,
WindowStyle = WindowStyle.None,
WindowState = WindowState.Maximized,
Topmost = true
};
darkwindow.Show();
MessageBox.Show("Hello");
darkwindow.Close();
and replace MessageBox.Show("Hello");
with mywindow.ShowModal();
. Possibly, you'll need to make mywindow
always on top.
Edit
Don't use darkwindow.Hide() instead of Close().