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
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