I'm looking for a way to interact between the Menu in MainWindow (where my XamDockManager is located) and a Floating ContentPane.
In Visual Studio 2010, if I right-click a document and select Float, selects some text in the floating document and then choose "Edit -> Cut" through the menu in VS2010 then that command is executed against the floating document and once the menu closes the floating document is still the active.
If I do the same thing using XamDockManager, clicking the menu changes the active window from the floating one to MainWindow, meaning that ActivePane is changed and once the menu closes the Floating window is no longer active. Is it possible to achieve the same behavior here as in Visual Studio? Thanks
Update, adding a screenshot of a Floating document and an active menu in Visual Studio. Notice how MainWindow.xaml still has focus when the Team-menu is opened.
Problem solved, thanks NathanAW!
http://stackoverflow.com/questions/6410146/dockable-windows-floating-window-and-mainwindow-menu-integration
This is basically an issue/behavior in WPF. Basically when you click anywhere on the main window's elements (e.g. the menu item), WPF focuses the FocusedElement of the root FocusScope within that Window. In WPF 4, MS added some properties to try and affect this (at least in so far as what VS needed) - specifically Keyboard.DefaultRestoreFocusMode and HwndSource.DefaultAcquireHwndFocusInMenuMode. The properties are discussed here.
That helps a little but there are still several issues. So while it won't focus the FocusedElement of the main window it still activates the main window and so the floating window becomes deactivated. This may or may not be a problem depending on your perspective. If it was an issue you could jump through hoops to try and prevent the WM_MOUSEACTIVATE from activating the main window. Either way though when you leave menu mode (e.g. click a menu item or press escape to leave menu mode), WPF will still focus the FocusedElement of the root FocusScope of the containing window. Now you could try to handle the InputManager's EnterMenuMode and cache the Keyboard.FocusedElement and then in the LeaveMenuMode call Focus that cached object (assuming there was a FocusedElement before). If you did these things then the previous floating window would be focused after leaving menu mode.
There will also be a problem if you are using RoutedCommands in those menu items. The issue there is that by default the command will bubble up the menu item/toolbar button/etc up to its containing focusscope - the Menu/Toolbar/etc. WPF then re-routes the RoutedCommand to the FocusedElement of the containing parent FocusScope - so the FocusedElement of the main window. So even with the above properties and regardless of whether you prevented the deactivation routed commands will still be routed to the main window and not to the floating window.
I found a similair posting by cryptoix posted in the xamRibbon section a while ago. It is as follows..."
I'm using 2010.1 and having an issue with floating windows and their ability to communicate with a context-sensitive menu in the ribbon of my main window.
The scenario I'm experiencing can be replicated as follows (assuming that a context-sensitive menu has been created for a Tabbed Document document):
1) View a Tabbed Document and observe that it's context-sensitive menu can be clicked and the contents accessed.2) Float the document (either by right-click > "Floating" or right-click > "Dockable")3) Click on the context-sensitive menu item. (At this point, it disappears for me)."
So far there have been zero solutions or suggestions for this. Is there a fix for this? I am currently upgrading to 2011.1 and would like to know if this has been addressed in this version or if it is still a know or unknown bug.