简体   繁体   中英

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.

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. those are not solve my issue

You could use the Deactivated event. Have a look at the MSDN for further information.

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. 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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