Nested docksites with MVVM

Docking/MDI for WPF Forum

Posted 2 years ago by Molly
Version: 22.1.1

I have a MainView with a Docksite that contains a TabbedMDIHost and ToolWindow. This is bound using DocumentItemsSource to a ObservableCollection of Views in my MainViewModel, lets call them ObservableCollection<Child1View> Child1ViewCollection.


<docking:DockSite x:Name="dockSite" DocumentItemsSource="{Binding Child1ViewCollection}">

       <docking:SplitContainer Orientation="Horizontal">

                <docking:ToolWindowContainer >
                    <docking:ToolWindow Title="Open Workspaces" DefaultDockSide="Left" Style="{StaticResource ToolWindowStyle}">


                    <docking:TabbedMdiHost x:Name="TabbedMdiHost_Workspaces" TabStripPlacement="Top"/>

Each Child1View.xaml then contains their own Docksite, bound in their DocumentItemsSource to an ObservableCollection<Child2View> Child2ViewCollection in Child1ViewModel.


<docking:DockSite x:Name="dockSite_Child" DocumentItemsSource="{Binding Child2ViewCollection}">
                        <docking:TabbedMdiContainer x:Name="TabbedMdiHost" TabStripPlacement="Top">

In my MainView the tab control populated with Child1View tabs works perfectly and fires WindowsRegistered / SourceChanged events when the collection is changed. But within the child view, although the Child2ViewCollection is initialised and populated, the views are never opened, no Window Registered / Requested or SourceChanged Events fire. If I explicitly add a document window in using XAML it does appear.

Any advice on where I am going wrong when the implementation of both docksites is the same?

[Modified 2 years ago]

Comments (1)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Molly,

Hmm, I would expect that to work in general.  One note is that you don't need to put a TabbedMdiContainer in the ChildView1.xaml because containers are generated as needed.  And really you should never put a x:Name or reference specific TabbedMdiContainers since they are created/destroyed as layouts change.  You DO want to keep Workspace and TabbedMdiHost elements in the XAML though, as those are fixed.  That wouldn't affect your scenario here though.

Maybe you could add something to the ChildView1.xaml that prints out what the DataContext is ("{Binding}") in a TextBlock and also another TextBlock to show what "{Binding Child2ViewCollection.Count}" is?  Perhaps the DataContext isn't what you think it is and that's why nothing is showing?

If it does come through as being populated correctly but still no document windows are generated, please make a new simple sample project showing this happening and email it to our support address.  Reference this thread in your email and exclude the bin/obj folders from the .zip you send so it doesn't get spam blocked.  Then we can debug with that and see what's happening.  Thanks!

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.