简体   繁体   English

当用户在其外部单击时,关闭WPF对话框窗口

[英]close a WPF Dialog Window when the user clicks outside it

GoodDay, Here i want to minimize the WPF Window, While user clicking outside of the window. 早安,在这里我想最小化WPF窗口,而用户在窗口外部单击。

I can easily minimize the window by this code 我可以通过此代码轻松地最小化窗口

mywindow.WindowState= WindowState.Minimized;

but i want minimize the window at the time of clicking outside of the window. 但是我想在单击窗口外部时最小化窗口。

i searched about that. 我搜索了。 But i can only got the output of various events like, FocusChanged,MouseMove,MouseDown like that. 但是我只能得到像这样的FocusEvent,MouseMove,MouseDown等各种事件的输出。 those are not solve my issue 那些不能解决我的问题

You could use the Deactivated event. 您可以使用Deactivated事件。 Have a look at the MSDN for further information. 请查看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. 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM