如何在两个不同的Xamarin Form页面之间切换? [英] How do you switch between two different Xamarin Form pages?

查看:962
本文介绍了如何在两个不同的Xamarin Form页面之间切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何在Xamarin Forms中的两个不同页面之间切换.

I'm trying to figure out how to switch between two different pages in Xamarin Forms.

不希望使用NavigationPage(该箭头具有自动显示的后退小箭头.

I do not wish to use a NavigationPage (which has that little back arrow that is auto displayed.

我有一个登录页面(这是一个ContentPage),并且该人通过身份验证后,我需要导航到我的仪表板页面(这是一个TabbedPage).

I have a Login page (which is a ContentPage) and once the person has authenticated, I then need to navigate to my Dashboard page (which is a TabbedPage).

例如

接下来,TabbedPage中的一个选项卡是已登录用户的个人资料.因此,我需要注销它们.因此,我将有一个按钮将其注销,这意味着我将需要将其导航回到登录"页面(即ContentPage).

Next, one of the Tab's in the TabbedPage is the profile of the logged in user. As such, I need to log them out. So i'll have a button to log them out, which means I will need to navigate them back to the Login page (which was that ContentPage).

我觉得我可能有两种模式用户可能会进入.

I feel like I have two modes the user might be in.

  • 未经授权. (ContentPage)
  • 已授权. (TabbedPage).
  • UnAuthorized. (ContentPage)
  • Authorized. (TabbedPage).

这就像我需要将AppMainPage更改为这两个中的任意一个一样?

It's like I need to change the App's MainPage to be either one of those two?

推荐答案

要将MainPage更改为另一个,只需执行以下操作:

To change MainPage to another just do:

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

App.Current.MainPage = new MyContentPage();

顺便说一句:您可以使用NavigationPage,然后使用以下命令隐藏工具栏:

BTW: You can use a NavigationPage and then HIDE the toolbar with:

NavigationPage.SetHasNavigationBar(this, false);

这篇关于如何在两个不同的Xamarin Form页面之间切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆