当用户在其外部单击时关闭 WPF 对话框 Window
close a WPF Dialog Window when the user clicks outside it
GoodDay,这里我想最小化 WPF Window,而用户在 window 外部单击。
我可以通过这段代码轻松地最小化 window
mywindow.WindowState= WindowState.Minimized;
但我想在单击 window 外部时最小化 window。
我搜索了一下。但我只能得到各种事件的输出,比如 FocusChanged、MouseMove、MouseDown 之类的。这些都不能解决我的问题
您可以使用 Deactivated
活动。查看 MSDN 了解更多信息。
A window is deactivated (becomes a background window) when:
A user switches to another window in the current application.
A user switches to the window in another application by using ALT+TAB or by using Task Manager.
A user clicks the taskbar button for a window in another application.
GoodDay,这里我想最小化 WPF Window,而用户在 window 外部单击。
我可以通过这段代码轻松地最小化 window
mywindow.WindowState= WindowState.Minimized;
但我想在单击 window 外部时最小化 window。
我搜索了一下。但我只能得到各种事件的输出,比如 FocusChanged、MouseMove、MouseDown 之类的。这些都不能解决我的问题
您可以使用 Deactivated
活动。查看 MSDN 了解更多信息。
A window is deactivated (becomes a background window) when:
A user switches to another window in the current application. A user switches to the window in another application by using ALT+TAB or by using Task Manager. A user clicks the taskbar button for a window in another application.