The last step before we can start the app for the first time is to set the MainPage property in the App.xaml.cs file. But first, we will delete the MainPage.xaml and MainPage.xaml.cs files that we created when we started the project since we won't be using them here:
- Delete the MainPage.xaml and MainPage.xaml.cs files in the MeTracker project, since we will be setting our MainView as the first view that the user sees.
- Use the Resolver to create an instance of MainView.
- Set MainPage in the constructor to the instance of MainView, as shown in the following code:
public App()
{
InitializeComponent();
MainPage = Resolver.Resolve<MainView>();
}
The resolver uses Autofac to figure out all the dependencies we need in order to create a MainView instance. It looks at the constructor of MainView and decides that it requires a MainViewModel. If MainViewModel has further dependencies, then the process iterates through...