我应该如何正确使用rootpage,以便我可以使用正确的navigatiobar导航/ pushasync到其他页面 .
现在它看起来像这样:
MainPage = new RootPage ();
我的根页:
public RootPage ()
{
var theMenu = new MenuPage (this);
theMenu.Title = "::";
Master = theMenu;
NavigationPage page = new NavigationPage(new StartPage ());
Detail = page;
}
如果我有这样的话,当我尝试导航到新页面时出现错误:
async void contactClick (object s, EventArgs e)
{
await Navigation.PushAsync (new ContactPage());
}
错误:“iOS上不支持全局支持PushAsync,请使用NavigationPage . ”
如果我改为:
MainPage = new NavigationPage (new RootPage ());
我有两个导航栏 . 我用...解决了它:
NavigationPage.SetHasNavigationBar (this, false);
...在我的RootPage上,但是当我导航到新页面并且它在android上崩溃时,它会给它一个奇怪的动画 . 有什么想法你会如何解决这个问题?
2 回答
据我所知,你有MasterDetailPage,你想在详细页面上执行导航 .
如果是这样,您应该通过Detail.Navigation.Push / Popasync(..)推送/弹出页面(您的详细信息页面已经是NavigationPage) .
如果此方法在MenuPage或RootPage中,那么你得到了
因为这个页面不是NavigationPages .
EDIT :如果要在导航后隐藏菜单,请将RootPage.IsPresented属性设置为false .
看看这些例子:
https://developer.xamarin.com/samples/xamarin-forms/PhonewordMultiscreen/
https://developer.xamarin.com/samples/xamarin-forms/Navigation/TabbedPageWithNavigationPage/