c# - How to know if Window Close was completed or cancelled? -


wpf application. window1 can open windowa.show(), windowb.show(), windowc.show()

when close window1 want close open windows (a, b , c).

on window1_closing event call

windowa.close(); windowb.close(); windowc.close(); 

on window closing of of these cancel = true can called , windowa (or b or c) won't close. don't want close window1 (the parent). how know in window1_closing if of child windows cancelled (not closed)?

  1. window.closed event fired after window closed. either move logic eventhandler of closed event, or use event send flag:

    bool isclosed = false; windowa.closed += delegate { isclosed = true; }; windowa.close();  if (isclosed) {  } 
  2. application.current.windows collection of opened windows:

    windowa.close(); bool isclosed = !application.current.windows.oftype<window>().contains(windowa); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -