I have a WPF window (window1) whose owner is window2. If a user clicks on window2, or the desktop, or anything else to make window1 not on top of the z-order, I want to set window1's visibility to hidden. I.e., the window either needs to be on top, or hidden. Is this possible?
+3
A:
Yes.
public Window1()
{
InitializeComponent();
this.Deactivated += new EventHandler(Window1_Deactivated);
}
void Window1_Deactivated(object sender, EventArgs e)
{
Visibility = Visibility.Collapsed;
}
Note that this will also remove it from the TaskBar.
Bubblewrap
2009-02-04 21:36:21