1

I have a Xamarin.forms.Maps in a ContentView and I am using that view in a ListView. I need to open a new page when clicking the map.

I tried like below:

MapClicked="MapClicked"

private async void MapClicked(object sender, MapClickedEventArgs e)
{
    var item = (History)((Map)sender).BindingContext;
    await Navigation.PushModalAsync(new Pages.Page1());
}

When I tap the map these lines are triggering, but Page1 is not opening. So what is the exact way to open a ContentPage from a ContentView?

Reference: Xamarin Forms: How to bind the position value of Xamarin.forms.Maps inside the ListView?

Cfun
  • 8,442
  • 4
  • 30
  • 62
Sreejith Sree
  • 3,055
  • 4
  • 36
  • 105
  • Hi, I created a baisc demo to test the mapView in a `ListView`. The navigation works fine when clicking the map. How did you define the listView? Please post the related code about the xaml, it'll help to reproduce the issue to get the cause. – Jarvan Zhang Jan 11 '21 at 11:26
  • @JarvanZhang-MSFT For the map, I am using a contentview. Navigation is to implemented on the contentview. https://stackoverflow.com/questions/65390620/how-to-bind-the-position-value-of-xamarin-forms-maps-inside-the-listview – Sreejith Sree Jan 12 '21 at 10:02

1 Answers1

1

You should have NavigationPage as root page to navigate. read more at: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/hierarchical

eakgul
  • 3,658
  • 21
  • 33