Input binding for docked document in another monitor

Ribbon for WPF Forum

The latest build of this product (v21.1.3) was released 16 days ago, which was before this thread was created.
Posted 10 days ago by Procam
Version: 21.1.3
Platform: .NET 5.0
Environment: Windows 10 (64-bit)

Hello Actipro,

In main window I have a docksite with 2 document windows inside (DW1 and DW2). In that main window are defined some input bindings. For example, Ctrl + X to close the active document window. It works ok until I dock e.g. DW2 to another monitor and is active. When pressing Ctrl + X nothing happens. I presume that it occurs because the DW2 is now "outside" the main window. Looking at Live Visual Tree in VS it is called [wQ+jH0] of type ActiproSoftware.Internal.wQ+jH0.

I could handle that with some style in the application level (App.xaml), but i see that the docked DW2 is in some actipro internal type.

How can I set input bidings also in the actipro internal obejct?

Comments (3)

Posted 9 days ago by Actipro Software Support - Cleveland, OH, USA


Yes WPF input bindings in general only work in the same visual hierarchy and don't cross Window or Popup bounds.  Since a floating docking window is hosted by a separate WPF Window, that's why the input bindings defined on the main Window aren't found in that scenario.

One workaround for this issue would be to define the input bindings on the docking window controls themselves, but that's not ideal.

Another option would be to create a class that inherits DockSite and override the InitializeFloatingWindow method.  That method is passed the WPF Window that is used to hold a new floating dock host when it is first created.  Therefore you could clone your input bindings to that Window as it's created so that they are available to all docking windows that are in that floating dock host.  That's probably the best approach for this scenario.

Actipro Software Support

Posted 7 days ago by Procam

I use MEF container defined in App.xaml.cs for my services, one of the services keeps the Input bindings, so the bindings are avaiable everywhere through constructor/property injection and can modify the input bindings collection. I am trying to get this service from the container in my new CustomDocksite (that inherits from Docksite) but it is always null. It seems because it was defined in App.xaml.cs and is not available elsewhere?

For the moment I solved this making 'static' the respective service input bindings, so these input bindings are now available everywhere and can be passed to the new window:

protected override void InitializeFloatingWindow(Window window)
foreach (InputBinding inputBinding in AppInputBindings.InputBindings)

Do you know another way how to 'clone' the main window Input bindings? Or how can I get the main window from inside the CustomDockSite?

[Modified 7 days ago]

Posted 6 days ago by Actipro Software Support - Cleveland, OH, USA


I'm not sure what to suggest in terms of MEF not finding the service in your scenario.  But as far as getting the main Window from your CustomDockSite, any of these lines would work in your InitializeFloatingWindow method:

var mainWindow1 = Window.GetWindow(this);
var mainWindow2 = ActiproSoftware.Windows.Media.VisualTreeHelperExtended.GetAncestor<Window>(this);
var mainWindow3 = ActiproSoftware.Windows.Media.VisualTreeHelperExtended.GetRoot(this) as Window;

Then once you have that main Window, you can clone the input bindings to the "window" passed in to the method.

Actipro Software Support

Add Comment

Please log in to a validated account to post comments.