Caliburn.Micro and custom UserControls

This drove me crazy - perhaps it's just that I didn't RTFM - but maybe this will help someone avoid my pain.

In the main view of the EasyPlayer project, I wanted to hive off a part into a child control, so I go ahead a create a new User Control (NowPlayingView), delete the .xaml.cs auto-generated code behind file and move the xaml from the main view into the new NowPlayingView.xaml file:

<StackPanel Orientation="Vertical">
  <StackPanel Orientation="Horizontal">
    <TextBlock Text="Currently playing:  " />
    <TextBlock Name="CurrentlyPlaying" />
  </StackPanel>
  <MediaElement Name="MediaPlayer" Stretch="UniformToFill" />
</StackPanel>

The main view is now simplified:

xmlns:mc="clr-namespace:EasyPlayer.MediaControl"
...
<mc:NowPlayingView x:Name="MediaControl" />

I create the NowPlayingViewModel class with a simple property to make sure everything is wiring up OK:

public string CurrentlyPlaying { get { return "TODO"; } }

Nothing

But I fire up the application and nothing is appearing - not the "Current playing" text block or the TODO text. So I go back and check the samples/documentation and finally figure out that as this is essentially 'view first', I need to manually bind the ViewModel to the View using the following:

<UserControl ...
  cal:Bind.Model="EasyPlayer.MediaControl.NowPlayingViewModel">

Update IoC Lookup

This string is used as the 'key' in the GetInstance method as part of the IoC resolution, with a null type, so I add the following to AppBootstrapper:

protected override object GetInstance(Type serviceType, string key)
{
  if (serviceType == null && !string.IsNullOrWhiteSpace(key))
  {
    serviceType = Type.GetType(key);
    key = null;
  }
  // ... as before...

InitializeComponent

Still nothing! The code looks more or less the same as the ViewFirst sample that comes with Caliburn.Micro but for some inexplicable reason is not working. Finally, I just try adding a new UserControl which only contains a TextBlock: and it works. I then realise the stupid mistake - I deleted the code behind class containing the all important InitializeComponent method call in the constructor. As this is view first, this call needs to be there to make it all work.

I add the NowPlayingView.xaml.cs code behind file back to the project and I'm back on track.

public partial class NowPlayingView : UserControl
{
  public NowPlayingView()
  {
    InitializeComponent();
  }
}

Comment Guidelines
See the FAQ for details on the full rules and guidelines. No Spam. Write clearly and thoughtfully - no bad language.