After docking a ToolWindow, the bindings are not working.

Editors for WPF Forum

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Version: 19.1.0684
Avatar

Hello!

I have an application which uses a lot of tool windows. Inside the main window, I bind the DataContext of each tool window to some object from the parent DataContext (view model) of the main window.

If I drag a tool window and dock it in the same place it was I have no problems but if I dock it in a new place (probably creating automatically in the background other split and tool window containers) the bindings seems to get lost.

It’s like the tree chain of parent – child elements is broken somewhere. (DataContext become null for the docked tool window).

Kind regards,

Daniel

Comments (2)

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

I have a workaround for now.


I do the bindings using the ElementName option directly connecting to the main window

<toolWindows:Test x:Uid="TestToolWindow"
                                x:Name="TestTW"
                                DataContext="{Binding DataContext.Test, ElementName=mainWindow}">

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

Hi Daniel,

Please see the "Docking/MDI / Troubleshooting" topic in the documentation that comes with the product.  That has a section that talks about docking window DataContexts.  To sum up, as layout changes occur, UI controls are moved around and the visual tree is changed.  DataContext inheritance won't work properly with that going on.  That being said, there's an easy workaround in that topic that you can implement, which is similar to what you ended up doing.


Actipro Software Support

The latest build of this product (v24.1.1) 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.