简体   繁体   中英

Navigate to next page in xamarin forms on tap gesture

I have click event for label to go to next page but in xamarin forms I am not able to get proper statement to move on next page from main page. I have used following code.

var forgetPassword_tap = new TapGestureRecognizer();
forgetPassword_tap.Tapped += (s, e) =>
{
    // App.Current.MainPage = MyContentPage;
    App.Current.MainPage = new NavigationPage();
    App.Current.MainPage.Navigation.PushAsync(page:MyContentPage());
};
forgetPasswordLabel.GestureRecognizers.Add(forgetPassword_tap);

In the above statement I got error like "MyContentPage" is not valid argument.

If instance of page MyContentPage has already been created, this ought to do it:

App.Current.MainPage = new NavigationPage(MyContentPage);

If not, and MyContentPage is a type, not an instance:

App.Current.MainPage = new NavigationPage(new MyContentPage());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM