Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1485
Routed commands and floating panes
posted

Hi,

I just ran into a problem I (or a tester) should have noticed a long time ago.

Let's say I have a usercontrol which contains a dock manager, which contains a number of panes, each with a different usercontrol.

The user controls in the panes are "dumb" - the main usercontrol (the one that owns the dock manager) has routed command bindings, and supplies data for the controls to display.  If, for example, the user clicks on a row in a XamDataGrid in a control, it executes a routed command that is defined in the main control.  The main control does whatever has to be done, and updates the datacontext of the various panes.

This works as long as all the panes are docked.  However, I just noticed that if I undock a pane that hosts a usercontrol that uses a routed command and leave the pane floating, then the routed command never gets executed.  This actually makes sense (I think): When a pane is floating, it's no longer part of the element tree of the main usercontrol like it was while docked (I sort of confirmed that with Snoop.)

Any suggestions as to how to handle this kind of interaction without using routed commands?  I'm kind of scr***d here!

Thanks,
Michel

Parents
No Data
Reply
  • 54937
    Offline posted

    One thing that you could do is to handle the ToolWindow(Loaded|Unloaded) events. When a ToolWindow is loaded you could add command bindings to it so that you could get the routed commands that bubble up to it and then hand them off to the usercontrol to handle (or use the same methods for the handler). When the ToolWindowUnloaded is invoked you probably want to unhook/remove those bindings so you don't root the toolwindows.

Children