简体   繁体   English

点击手势以Xamarin形式导航至下一页

[英]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. 我有标签的单击事件可转到下一页,但以xamarin格式,我无法从主页面上获取正确的语句来移至下一页。 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. 在上面的语句中,出现类似“ MyContentPage”的错误参数无效的错误。

If instance of page MyContentPage has already been created, this ought to do it: 如果页面MyContentPage实例已经创建,则应该这样做:

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

If not, and MyContentPage is a type, not an instance: 如果不是,并且MyContentPage是类型,而不是实例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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