Hello everyone, I'm facing a problem with navigation in MasterDetail page,
Here is what I want to do
MasterDetail Page -> On the DetailPage I have a listview that when I tap the item I want to go to a new Hierarchical NavigationPage -> Go to the page of the Item clicked.
If I implement on the code behind the XAML Detail Page it works, It navigate to the PlacePage fine the way I want.
private async void MyListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
if(e.SelectedItem == null)
return;
var placeData = e.SelectedItem as Place;
await Navigation.PushAsync(new PlacePage(placeData));
MyListView.SelectedItem = null;
}
But I want to implement using MVVM, I have a Navigation Service that I call this way from the ViewModel:
private async void PlaceTapped(Place place)
{
await this._navigationService.NavigateToPlace(place);
}
And inside the navigation service I have:
public async Task NavigateToPlace(Place placeData)
{
try
{
await Application.Current.MainPage.Navigation.PushAsync(new PlacePage(placeData));
}
catch(Exception ex)
{
Debug.WriteLine(ex);
}
}
It is the same PushAsync as in the Codebehind but It throw this error:
System.InvalidOperationException: PushAsync is not supported globally on Android, please use a NavigationPage.
Can anyone help me?