As part of a Xamarin.Forms application I have implemented a custom navigation header. The Navigation Header is simply a Content View that has its own View Model. Pages which need to participate in the navigation experience of the application include this content view within them.
This application is using Prism 7 and to perform navigation within View Models I would like to use the Prism INavigationService. The issue I have with this is getting a reference to the INavigationService inside the View Model for the navigation Content View.
Accessing the INavigationService in a ContentPage is trivial, simply have this injected using constructor injection, the problem is that injecting INavigationService into the View Model for a Content View is not possible using prism 7 - this is confirmed by Brian Lagunas in his reply to this topic on the Xamarin Forums.
In his response Brian quotes as follows:
You can't inject the INavigationService into a ContentView's VM. You should either expose a property that you can bind to from your VM, or set it in code when the ContentView is loaded.
With the above in mind, what would be the approach to getting a reference to the INavigationService in the View Model of a Content View? I already have the wiring of the Content View to its View Model working correctly.