The official Fatica Labs Blog! RSS 2.0
# Thursday, 03 November 2011

As we know the Caliburn Micro library implements a screen conductor to handle multiple screen models with only one active, typically used for tabbed views, that is easy to implement by deriving your model from Conductor<IScreen>.Collection.OneActive. This works out of the box with the standard tab control, but it is not possible to use it for example with the tabbed documents in AvalonDock. The only solution I found, that for some reason I will say below, is this one. I don’t like this solution because it force to write code inside the view, that is not acceptable in a pure MVVM solution, so I preferred to insulate the code in an attached behavior. In addition the presented solution will works correctly with the Activate/Deactivate/CanClose strategy on each document. We just need to modify the view markup as in the example below:

As you can see we just added an attached property UseConductor.DocumentConductor that we bind to the current model. Of course the model is a OneActive screen conductor. The behavior take care to connect the document items of the DocumentPane with the screen conductor items. If each screen implements IScreen, the proper Activate/Deactivate/CanClose are called, so we can even handle the case of canceling the close of a dirty document. Here the attached behavior code: An example MainModel can be the following one:

( we just add some random document to see how it behave )

And here below an example of a single screen  model:

So we have the conductor, without touching the view code, and without creating a custom screen conductor.

Thursday, 03 November 2011 19:52:59 (GMT Standard Time, UTC+00:00)  #    Comments [6] - Trackback
Caliburn | WPF | CodeProject
Tracked by:
" [Pingback]
"" (h... [Pingback]

Thursday, 17 November 2011 17:22:18 (GMT Standard Time, UTC+00:00)
I think the code example for MainModel is the same as the code example for the UseConductor.
Thanks, interesting post
Thursday, 17 November 2011 18:25:30 (GMT Standard Time, UTC+00:00)
@John thanks for pointing: I modified the link to the gist.
Felice Pollano
Wednesday, 22 February 2012 21:12:51 (GMT Standard Time, UTC+00:00)
At last I got this to work - it's taken hours to work out why I was getting a DocumentPane but with no content.

Turns out that I needed to fire off the TabModels from OnViewLoaded of MainViewModel, so that "conductor.Items.CollectionChanged" is set up before the TabModels are added to Items.

Good learning experience.
I'd falled back to this version for AvalonDock v1.3, as I could not get AvalonDock v2 to work with Caliburn.Micro, but the Control's author does say it will be ready March 2012, so I'll look again later.

Thanks for your clever idea.
Tuesday, 28 February 2012 23:31:03 (GMT Standard Time, UTC+00:00)
Hi again,
I've got your DocumentConductor working with AvalonDock v2 now, now that a DocumentsSource has been added to the code.
Do let me know if you'd like it.
Wednesday, 29 February 2012 06:51:56 (GMT Standard Time, UTC+00:00)
This is great! do you share somewhere your results?
Saturday, 03 March 2012 23:54:51 (GMT Standard Time, UTC+00:00)
Hi Again,

I've put my solution up on my blog.

Hope you find it interesting, and can improve on it.
Perhaps we can influence the AvalonDock developer to add more functionality that would aid usage with CM.


All comments require the approval of the site owner before being displayed.
Please login with either your OpenID above, or your details below.
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, strike, strong) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
My Stack Overflow

Send mail to the author(s) E-mail

profile for Felice Pollano at Stack Overflow, Q&A for professional and enthusiast programmers
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2019
Felice Pollano
Sign In
Total Posts: 157
This Year: 0
This Month: 0
This Week: 0
Comments: 127
This blog visits
All Content © 2019, Felice Pollano
DasBlog theme 'Business' created by Christoph De Baene (delarou) and modified by Felice Pollano