I’m trying to understand the HelloScreens sample that comes with Caliburn.Micro. The ShellView.xaml includes a ContentControl at the bottom. Can someone please explain the importance of this element? I have tried to comment it out without seeing any difference.
<UserControl x:Class="Caliburn.Micro.HelloScreens.Shell.ShellView"
xmlns:...>
<Grid>
<local:TiledBackground SourceUri="/Resources/Images/backgroundtexture.png" />
<Image Source="/Resources/Images/backgroundshadow.png"
Stretch="Fill" />
<ct:DockPanel>
<.../>
</ct:DockPanel>
<!-- Whats this one for? --/>
<ContentControl x:Name="Dialogs"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"/>
</Grid>
</UserControl>
It’s binded to the viewmodels Dialogs-property, which is an custom implementation of IConductActiveItem, but what is it used for?
Whenever you have a
ContentControlwith the same name as a view model property, Caliburn.Micro will find the corresponding view for that view model, inject the view into theContentControl, and bind up the view model to the view.In this case, the
Dialogsproperty is anIDialogManagertype as you say, which resolves toDialogConductorViewModel(a conductor type). So theDialogConductorViewis injected into the content control.This view displays the dialogs in the application, and if you look at the view, it also has a
ContentControlwhich displays the currentActiveItem. This is typical of a Caliburn.Micro conductor.Note that the
DialogConductorViewis always displayed over the content of the application inShellView, but theGridinside theDialogConductorViewis only visible if theActiveItemis not null.