This project is read-only.

How to use custom LayoutAnchorable as a View in MVVM

May 5, 2013 at 8:18 PM
Edited May 5, 2013 at 8:54 PM
I am trying to port a project from 1.3 to 2.0/MVVM.

In my project I have some classes derived from LayoutAnchorable (used to be a DockableContent) with complete XAML + CS.
I can add the pane using code such as:

MyLayoutAnchorable la= new MyLayoutAnchorable();
la.Content = myContent;
librariesPane.Children.Add(la);
la.Dock();

What I want in MVVM is whenever I add a MyViewModel in my Tools collection AvalonDock should use the corresponding View which is MyLayoutAnchorable.

I tryied to override BeforeInsertAnchorable and add a new MyLayoutAnchorable instead of the base LayoutAnchorable. But this didn't work.

The MVVM sample defines a DataTemplate for something similar, but I don't want to place the panes UI inside the MainWindow.xaml. I want to use the inherited LayoutAnchorables.


UPDATE: Ok, I think I need to rewrite my panes as UserControls so I can set them as the DataTemplate.