以轻击手势导航到xamarin表单中的下一页

时间:2016-03-07 05:24:52

标签: c# xamarin xamarin.ios

我有标签的点击事件转到下一页,但是在xamarin表单中我无法从主页面上获得正确的声明来移动下一页。我使用了以下代码。

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);

在上面的语句中,我收到了类似“MyContentPage”无效参数的错误。

1 个答案:

答案 0 :(得分:2)

如果已经创建了页面MyContentPage的实例,那么应该这样做:

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

如果没有,MyContentPage是一个类型,而不是一个实例:

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