How to Use Caliburn.Micro.Autofac
Using Nuget for Caliburn.Micro.Autofac
The nuget package id is Caliburn.Micro.Autofac. So you can install the package from the nuget package manager shell using the following command:
PM> Install-Package Caliburn.Micro.Autofac
or if you are more GUI minded, use the Add Package Reference dialog.
Getting the Code for Caliburn.Micro.Autofac
You can find the code for Caliburn.Micro.Autofac on github at https://github.com/dbuksbaum/Caliburn.Micro.Autofac.
Configuring Your Code to use Caliburn.Micro.Autofac
Assuming you just added Caliburn.Micro using nuget to your application, you should have a view, viewmodel, and IShell interface. If you followed the completion instructions, you will have modified the App.xaml file to reference the AppBootstrapper. If you haven’t done that, do it. Then open the AppBootstrapper.cs file. Replace the Caliburn.Micro AppBootstrapper with the following implementation.
1 public class AppBootstrapper : AutofacBootstrapper<ShellViewModel> 2 { 3 protected override void ConfigureBootstrapper() 4 { // you must call the base version first! 5 base.ConfigureBootstrapper(); 6 7 // override namespace naming convention 8 EnforceNamespaceConvention = false; 9 // change our view model base type 10 ViewModelBaseType = typeof(IShell); 11 } 12 }
Then compile and run.
