# Root ContentPage

This is by far the simplest, and the least flexible. It restricts us to having a single `ContentPage` for the entire application.

The objective here is quite simply to get a reference to a suitable `ContentPage` and assign it to `App.MainPage` in the App constructor, so if you're a bit of a maverick you can just new up your `ContentPage`, set its `BindingContext` to something, and make the assignment, something like this:

```csharp
var rootPage = new MyRootPage();
var vm = new MyRootPageVm();
vm.Init(/* ... */);
rootPage.BindingContext = vm;
MainPage = rootPage;
```

What if your `MyRootPage` or (more likely) your `MyRootPageVm`has dependencies? Things can start to turn ugly, so let's do this using IoC ...

Once you have added your Page and ViewModel to the IoC container (in MauiProgram.cs), you can do this:

```csharp
public partial class App : Application
{
    public App(IPageServiceZero pageService)
    {
        InitializeComponent();

        // Don't forget to call pageService.Init, or navigation will not work properly!
        pageService.Init(this);
            
        var mvvmPage = pageService.GetMvvmPage<MyRootPage, MyRootPageVm>();
        var mvvmPage.viewModel.Init(/* ... */);
        MainPage = mvvmPage.page;
    }
}
```

Simple.
