Distinguish between programatically and user closed DocumentWindow

Docking/MDI for WPF Forum

Posted 8 years ago by Oliver Rutsch
Version: 14.2.0611
Avatar

Hi,

 

we have a special situation where I have to decide if a document window in a dock site was closed by the user (with the cross on the right upper side or the context menu) or if it was closed programaticially (by some functions of my program or the docking site serialization when loading a new configuration).

 

Any ideas?

 

Thanks and bye

Oliver

Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Oliver,

You could probably set some flag on your end before you programmatically close the document window, then close it, then clear the flag.  That way, any window closed event handlers you have would be able to see that the flag was set and take action appropriately.


Actipro Software Support

Posted 8 years ago by Oliver Rutsch
Avatar

Hi,

 

of course, I can do that. But unfortunately there is more than one way to close this DocumentWindow programatically. We have a huge, highly multithreaded application and so the code get's scattered over all the functions, which can close DocumentWindows.

So the code would be much clearer if I could handle that directly in the WindowClosed/WindowClosing handler.

 

Thanks and bye

Oliver

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Oliver,

While we can track the logical kind of reason why something was closed (e.g. Close, CloseAllDocuments, etc.), we can't differentiate the source location of the close, such as between a programmatic Close (one you would call) vs. one triggered by a Close button.  Both of those flow down through the same Close method.  The button fires the CloseCommand, which calls the Close method.  All close buttons in UI and menus work the same.

It seems like you would have to track this on your end.  What if you made an extension method that did the logic mentioned in our previous reply and have all your spots in the code that close tool windows programmatically use that instead of the normal Close method?


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.