public class MainViewModel : ViewModelBase { private readonly INavigationService _navigationService; public MainViewModel(INavigationService navigationService) { _navigationService = navigationService; } public void NavigateToDetailsPage() { _navigationService.Navigate("DetailsPage"); } }
public class DetailsViewModel : ViewModelBase { private readonly INavigationService _navigationService; public DetailsViewModel(INavigationService navigationService) { _navigationService = navigationService; } public void CheckCanNavigate() { if (_navigationService.CanNavigate("DetailsPage")) { _navigationService.Navigate("DetailsPage"); } } }This code will check if the DetailsPage can be navigated to, and if it can, it will navigate to it using the INavigationService interface. In conclusion, the INavigationService is a powerful tool that allows you to navigate between pages in a Windows Phone 8.1 app. It requires the Prism Windows Runtime (PWR) package and is located in the Windows.UI.Xaml.Navigation namespace.