Which event to hook for "active" window for file menu commands?

Docking/MDI for WPF Forum

Posted 6 years ago by Alan McCormick
Version: 13.1.0580
Avatar

I have a tabbed MDI host which allows rafting. Outside of the docksite my main window has a file menu. The file menu has such commands as Save, Print, Export, Float, Dock (sorta similar to Visual Studio). I'm trying to make these commands target the window that is currently active by hooking into either DockingWindow.Activated event or the Prism Region IActiveAware changed notification and updating which window is the target of the command. Here's what happens..

  1. Open two tabbed documents
  2. raft one of them
  3. (toggle between them once) click inside the docked window then click back inside the rafted window
  4.  Now when I click the "Window" menu for example the float/dock command doesn't work because it has switched to the DocumentWindow inside the main application.

I put Debug.Writeline messages in the DockingWindow.Activated events and IsActive changed from the Prism region interface. Both of them get called when any interaction occurs on the main window, including carefully clicking the file menu to open it. Visual Studio for example, accurately tracks the currently active window so that file functions can correctly target the current document.

I need to be able to interact with my application's file menu without triggering an ActiveChanged Event for the document window (whichever incarnation of Active I use). How can I get this to work? 

Comments (1)

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

Hi Alan,

The problem there is that clicking a control in the main Window triggers WPF to focus the last focused control in the Window.  And since that control is probably the child content of the document window in your case, it becomes "active".

This post on StackOverflow describes a possible workaround for the scenario:

http://stackoverflow.com/questions/6410146/dockable-windows-floating-window-and-mainwindow-menu-integration


Actipro Software Support

The latest build of this product (v2018.1 build 0675) 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.