Xamarin forms: How to open a ContentPage from a ContentView?

Sreejith Sree 1,251 Reputation points
2021-01-11T09:52:03.743+00:00

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: https://learn.microsoft.com/en-us/answers/questions/205619/xamarin-forms-how-to-bind-the-position-value-of-xa.html

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. Alessandro Caliaro 4,196 Reputation points
    2021-01-11T09:54:54.99+00:00
                await Application.Current.MainPage.Navigation.PushAsync(new Pages.Page1());
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.