I have several Tool Windows and several Document Windows. For now each Document Window contains the same content (in my case it’s a map). My project is also using the MVVM pattern and an event bus (Event Aggregator) to send events/messages between each of the View Models. I have a Tool Window that contains a button that is supposed to tell the “active” Document Window to do something. For this example I want the map to zoom to a specific location. Since the button is on a Tool Window it becomes IsActive=true at the time the button is clicked. Thus all of the Document Windows are IsActive=false. If all of the Document Windows are docked on top of each other I can check the IsSelected to know which Document Window should reposed to the event. If two or more of the Document Windows are docked side-by-side then both are IsActive=false and IsSelected=true at the time of the button click in the Tool Window. I cannot tell which Document Window should respond to the event.
I believe that the DockSite might be able to tell the difference somehow and I might be able to use the LastActiveDateTime and get the most recently active/selected Document Window. The problem here is each Document Window does not know about the others and my ViewModels do not have any reference to the DockSite. The Document Windows need to know if they should respond to the event based on their current “state”. I was hoping that a combination of IsOpen, IsActive, and IsSelected would be enough but in the case where two or more are docked side-by-side I can’t tell which one should respond to the event.
Any suggestions would be greatly appreciated.