分配App.MainPage时MasterDetailPage上缺少菜单按钮 [英] Missing menu button on MasterDetailPage when assigning App.MainPage

查看:157
本文介绍了分配App.MainPage时MasterDetailPage上缺少菜单按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小应用程序,需要从ContentPage交换到MasterDetailsPage.

I got a little App where I need to Swap from a ContentPage to a MasterDetailsPage.

MainPage = new NavigationPage(new MyContentPage());

现在,如果登录成功,我想将Root更改为MainPage = new NavigationPage(new MyMasterDetailpage());.

Now if the login succeed I want to change the Root to MainPage = new NavigationPage(new MyMasterDetailpage());.

显示了MasterDetailsPage,但是那时导航栏中的按钮不见了.

The MasterDetailsPage is shown, but the Button in the Navigation bar is missing then.

如果我只是使用

Navigation.PushModalAsync(new MyMasterDetailpage());

我什至没有导航栏,

Navigation.PushModalAsync(new NavigationPage(new MyMasterDetailpage()));

菜单图标再次丢失.

在这里我能做什么?

更新

似乎我的问题仅在Android上存在,不知道new NavigationPage(new MyDetailView)汉堡包仅在android上出现.

It seems that my problem is only on Android, didn't know that the new NavigationPage(new MyDetailView) hamburger only appears on android.

推荐答案

我遇到了同样的问题.但是解决方案是使流程不同.您首先要加载登录视图,然后显示MasterDetail的视图.我如下解决了这个问题:

I had the same problem. But the solution was to make different the process. You wants to load, initially, the login view and then you show the view of the MasterDetail. I solved this as follows:

启动应用程序时,我将创建MasterDetail的视图并立即将登录视图显示为对话框,如果登录成功,则只需关闭对话框即可.代码看起来像这样:

When you start the application, I create the view of the MasterDetail and immediately show the login view as a dialog, if the login is successful simply close the dialog. The code would look something like this:

public App()
{
    DependencyService.Register<IMessageService, MessageService>();
    DependencyService.Register<INavigationService,NavigationService>();

    InitializeComponent();

    MainPage = new NavigationPage(new MasterDetail());

    MercaFacil.App.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new LoginView()));
}

成功登录后,只需调用PopModalAsync()方法

When the login is successful simply called the PopModalAsync() method

这篇关于分配App.MainPage时MasterDetailPage上缺少菜单按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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