This project is read-only.

[Version 2.0] MVVM multiple views loaded via user controls

Nov 1, 2012 at 6:07 PM

First of all, Good effort on AvalonDock.  Looks great and provides a great framework from which to build rich UI applications.

Secondly, I have a question in relation to multiple Views being loaded dynamically.

We are deprecating and old MDI implementation and have opted to do this with AvalonDock.

The problem we have is, we have had to modify the AvalonDock codebase itself to hold an ObservableCollection of FileViews instead of the pre-designed FileViewModel ObservableCollection. 

This put simply doesn't feel right as we didn't want to amend the core codebase of AvalonDock in our implementation.

I suppose the question I'm asking is, is there a cleaner/better way of implementing a multi-View application rather than hosting all the UI elements inside the single MainWindow.xaml style implementation?  Without modifying the way AvalonDock Project/DLL itself is coded?







Nov 2, 2012 at 8:49 AM

Thought the code snippet might help, In the LayoutItem.cs file, we have modified below line of code which was originally

Model = model.Content   


// Modified code : Added casting with UserControl as we are using Collection of UserControl instead of Collection of ViewModel

Model = (model.Content as UserControl).DataContext;

This was to allow us to handle the observable collection of Views/UserControls then derive the viewModel from them.

Nov 9, 2012 at 10:23 PM

I have written an article on this I think this should be helpful since it extends AvalonDock without touching its source: