I have a Xamarin.Forms project, and I have a custom control that should open a new page when tapped. Unfortunately, nothing happens when I call Navigation.PushAsync(...);. I've read countless StackOverflow questions (such as this one) and Xamarin Forums threads and done several Google searches, but none of the solutions seem to solve my issue.
ContentView, as all Xamarin.Forms views
do.src is a custom class that contains some data points that
are used by this control and EventDetailsPage.PushAsync() does nothing.NavigationPage is used (such that it becomes myNavigationPage.Navigation.PushAsync(new EventDetailsPage(src));).Page and uses it in away similar to the above point.My control's constructor:
public EventControl() {
InitializeComponent();
GestureRecognizers.Add(new TapGestureRecognizer() {
Command = new Command(() => Navigation.PushAsync(new EventDetailsPage(src)))
});
}
Typically, asking a new question on StackOverflow is my last resort when nothing else that I've tried solved my problem. Any help is appreciated.
Change your App.cs like this
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage());//Very important add this..
//MainPage = new MainPage(); //not like this
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With