DocumentWindow Event Order

Docking/MDI for WPF Forum

Posted 14 years ago by Mick
Version: 9.2.0510
Avatar
Is there any way to change the order that the events get fired for DocumentWindows?

Here is my situation: I have a "context" item in my software that comes from a document tab - an item that is the "currently scoped" item to the end user. It is the item that current actions in my software should be performed against (think about spell-check in an MS-Word application - when you press F7, is only spell checks the document at the forefront of the application).

The events are firing in what seems to me to be a strange order: WindowActivated fires BEFORE WindowClosed. It would be easy to do this:

- Window 1 closed -> Set global item to null
- Window 2 activated -> Set global item to window 2's item (if it's valid)

However, using the desired the flow above and the current order of events, I have to track what window 2 does to the global item and switch window 1's close behavior accordingly (i.e. do I set the global item to null if window 2's item is invalid?).

The reason I desire this logic to be in the WindowClosed() method of window 1 (setting null) as opposed to the WindowActivated() method of window 2 is because window 2 does not necessarily have a "context" item that will be set. It seems like better encapsulation to have the window responsible for setting the item in the first place be responsible for cleaning it up afterward.

Thank you,
Mick

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mick,

You should be able to use the WindowClosing event instead. That event is fired before next document is activated.

I've marked down a TODO item to review the event orders, but this would be a larger and breaking change.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.