This project is read-only.

[Version 2.0] Trying MVVM

Feb 23, 2012 at 10:42 AM
Edited Feb 23, 2012 at 11:41 AM

I noticed your starting to support MVVM, so I thought I'd try, but got stuck....

I've found that I could not add an Attached Property to LayoutDocumentPane as I could to v1.3's Document Pane.

Object of type 'AvalonDock.Layout.LayoutDocumentPane' cannot be converted to type 'System.Windows.DependencyObject'.

How much more work do you have to do and is the March release realistic.



Feb 23, 2012 at 12:43 PM

LayoutDocumentPane is no more a DependencyObject as it was in ver. 1.3. It's just class of the layout model.

Could you please explain better what you're going to achive? why the dep property?



Feb 23, 2012 at 6:09 PM

Thanks for responding so quickly.

In 1.3,
public class DockablePane : Pane
traces back to DependencyObject


I was trying to use Caliburn.Micro.


write a custom convention for Caliburn.Micro

I have the following in a UserControl, where Caliburn.Micro will create the tabs at runtime, based on the contents of the Items collection.
Do you think this is possible


    <Grid > 
            <avalonDockLayout:LayoutRoot >
                <avalonDockLayout:LayoutPanel >
                        <avalonDockLayout:LayoutDocumentPane x:Name="Items" />



Feb 23, 2012 at 7:03 PM

OK I see the problem reading the blog. I'm afraid that you have to wait upcoming release  of the new version.
There you'll find a new property DocumentsSource that you'll be able to bind to a collection of view model objects.




Feb 23, 2012 at 7:34 PM

Many thanks, Ado
I thought that might be the reason. Sorry to rush you.
I'll wait patiently.

Feb 28, 2012 at 3:00 PM

Hello Ado,

Thank you for the recent updates, and now I see DocumentsSource.

To use the Blog post above, or to write a Custom Convention, for Caliburn Micro I've been looking for an Event that is triggered when the Tab is changed by the user, like the Event in AvalonDock 1.3, thus;


Is there one, or one coming in a future update?
Or, if not, can you suggest a way I can emulate one



Feb 28, 2012 at 3:18 PM

New version raises several events after a content (anchorable or document) is activated.

You can use the dependency property DockingManager.ActiveContent that works on view level or you could attach to PropertyChanging/ed of the model root:

DockingManager.Layout.PropertyChanged += ... and check for "ActiveContent".

The layout model has also another property called LastFocusedDocument that returns last content (anchroable or document) that was focused.

In any case I always suggest you to attach via stadard binding to one of the above properties instead of subscribe to events.

(BTW I think that in final version I'll add something like ContentChanged event even if I don't like it :))



Feb 28, 2012 at 7:52 PM

Thank you Ado,
I now have Layout.PropertyChanged working. Your MVVM example has no Layout at all and confused me slightly.

In my Caliburn.Micro(CM) example each of AvalonDock's tabs is a ViewModel and they are managed by a feature of CM which controls which is active etc.
Hence the Blog post, which uses the Event to advise the CM manager called a conductor of the changes.
I now have this attached property solution working and you're welcome to it as another example if you wish.

Your MVVM example has one VM managing all the tabs, so I need to do a bit more thinking as to whether I can use property as you suggest!!



Mar 4, 2012 at 12:05 AM

Sorry for my self promotion, but here are my solutions for AvalonDock v2 with Caliburn Micro

hope it's of interest to others