I have a control that uses the AvalonDock (2.0) DockingManager to display a set of documents controlled by the underlying view model:
<avalonDock:DockingManager DocumentsSource="{Binding Items}"> <avalonDock:DockingManager.LayoutItemContainerStyle> <Style TargetType="{x:Type avalonDockControls:LayoutItem}" BasedOn="{StaticResource DocumentItem}"/> </avalonDock:DockingManager.LayoutItemContainerStyle> <avalonDockLayout:LayoutRoot> <avalonDockLayout:LayoutPanel Orientation="Horizontal"> <avalonDockLayout:LayoutDocumentPane/> </avalonDockLayout:LayoutPanel> </avalonDockLayout:LayoutRoot> </avalonDock:DockingManager>
The document view model has the IsSelected property, and when the view model is selected, I want to select and show the document in the DockingManager . To do this, I updated the Style for LayoutItem as follows:
<Style x:Key="DocumentItem" TargetType="{x:Type avalonDockControls:LayoutItem}"> <Setter Property="Title" Value="{Binding Model.TabTitle}"/> <Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}"/> </Style>
This approach works great when the control is hosted in WPF, but when the control is hosted in VSPackage, selecting a document in the view model most often does not cause the selected document to not be displayed. In the image below, the user clicked on the node client for editing, but the client document did not appear.

The view model level sets IsSelected as expected, and when the control used TabControl , the selected document was always shown at the top.
This is a problem in AvalonDock. What I find is when LayoutItem selected when choosing a view model, the first document in the list is reset to true at the LayoutDocument/LayoutContent/LayoutElement , which seeps back and resets IsSelected to true in the LayoutItem layer. I would like to bind IsSelected to my view model at the LayoutDocument/LayoutContent/LayoutElement , but there is no DependencyProperty at this level.
I tried alternative methods of binding IsSelected to my view model, but so far without success. Anyone else run into this issue? Do you know about workarounds or other approaches? I would not want to resort to using an approach other than MVVM just to select a document.
Edit: It looks like this problem may be unclear, since it is difficult for me to create a test play example, even with VSPackage. In the following test case, which simulates the actual controls using two ToolWindow and Mediator messages, selecting a document works fine.

This test case (with a WPF application and VSPackage) is available here (click Tools=>My command name to launch the tool windows and enter the name of the document in one window to select or create and select a document in the window using the DockingManager ).