The official Fatica Labs Blog! RSS 2.0
# Thursday, November 03, 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, November 03, 2011 7:52:59 PM (GMT Standard Time, UTC+00:00)  #    Comments [6] - Trackback
Caliburn | WPF | CodeProject
Tracked by:
" [Pingback]
"" (h... [Pingback]

Thursday, November 17, 2011 5:22:18 PM (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, November 17, 2011 6:25:30 PM (GMT Standard Time, UTC+00:00)
@John thanks for pointing: I modified the link to the gist.
Felice Pollano
Wednesday, February 22, 2012 9:12:51 PM (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, February 28, 2012 11:31:03 PM (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, February 29, 2012 6:51:56 AM (GMT Standard Time, UTC+00:00)
This is great! do you share somewhere your results?
Saturday, March 03, 2012 11:54:51 PM (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