Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 WPF 窗口 (window1),其所有者是 window2。如果用户单击 window2、桌面或其他任何东西以使 window1 不在 z 顺序之上,我想将 window1 的可见性设置为隐藏。即,窗口需要在顶部或隐藏。这可能吗?
是的。
public Window1() { InitializeComponent(); this.Deactivated += new EventHandler(Window1_Deactivated); } void Window1_Deactivated(object sender, EventArgs e) { Visibility = Visibility.Collapsed; }
请注意,这也会将其从任务栏中删除。