> For the complete documentation index, see [llms.txt](https://yanxiaodi.gitbook.io/xamarin-mvvmcross-handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yanxiaodi.gitbook.io/xamarin-mvvmcross-handbook/implementing-masterdetail-layout-in-xamarin.forms-by-mvvmcross/creating-the-master-detail-page/creating-the-viewmodel.md).

# Creating the ViewModel

Next, add a new class file called `MasterDetailViewModel` in the `ViewModels` folder in the MvxFormsMasterDetailDemo.Core project. Change it to inherit from `MvxViewModel` class. Usually, we also need to use the `NavigationService` to implement the navigation in the ViewModel. So inject the instance of `IMvxNavigationService` by using dependency injection:

```
using MvvmCross.Navigation;
using MvvmCross.ViewModels;

namespace MvxFormsMasterDetailDemo.Core.ViewModels
{
    public class MasterDetailViewModel : MvxViewModel
    {
        readonly IMvxNavigationService _navigationService;

        public MasterDetailViewModel(IMvxNavigationService navigationService)
        {
            _navigationService = navigationService;
        }
    }
}
```
