Using avalondock seems to be fairly challenging in a MVVM environment. As soon as I detach a DocumentPane from the shellview, I loose the corresponding datacontext and my view is empty. When reattaching, it gets back to normal.
Does anyone have a solution ?
Here’s what I use currently; my app hase a couple of dockable panes, each having their own viewmodel. These viewmodels are exposed as properties from the main window’s viewmodel, which is also the DataContext of the main window. The trick is to refer to that datacontext using the static Application.Current instance’s MainWindow.DataContext.
For example:
MainWindow’s xaml:
Not sure how this works out for large modular applications though, but I’ve seen a sample application in Prism being used with Sofa (an AvalonDock wrapper) so you might want to check out how they did it.