# Xamarin Forms with Ninject navigation service

I am new to Xamarin Forms and I have been searching online finding ways to set up navigation in a MVVM fashion. In particular I am designing around a concept I found here. However, I am using Ninject to have a ViewModelLocator type object in my application.

Here is the code to my Locator object:

public class Locator
{

public const string MainPage = "MainPage";

{
//Setup services
_kernel = new StandardKernel();
_kernel.Bind<IDialogService>().To<DialogService>();
}

public MainViewModel MainViewModel
{
get { return _kernel.Get<MainViewModel>(); }
}

{
}
}


Now instinctively something is telling me that it may be a smell to have my locator require a INavigationService, because my locator should not be concerned with this, right?

The reason I am doing this is because my NavigationService requires some configuration to map the views. I did attempt to bind the NavigationService as I did the dialog service, and then resolved it in my application start up and set the configurations, but it didn't seem to keep these configurations when it resolved my view model dependencies, e.g., the views could not be found in the dictionary. (No longer an issue, just a side note)

Here is the code in my application startup:

public App()
{
InitializeComponent();

//Instantiate locator and add to resources for XAML reference

var nav = new NavigationPage(new MainPage());

//Assign main page and initialize navigation
MainPage = nav;
}


Just in case you are wondering about the addition of the locator as an application resource, here is an example of how I am using that -- if you find it relevant:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"