Missing Menu Button On Masterdetailpage When Assigning App.mainpage
Solution 1:
NavigationMenu appears in MasterDetailPage
when the Detail
page is a NavigationPage
. So rather than pushing MasterDetailsPage to Navigation stack, you may set it as MainPage. And then within MasterDetailPage, you need to add DetailPage within a NavigationPage.
You can set the Icon for the menu with Icon property of MasterPage
Here is an example below,
publicclassDashboardPage : MasterDetailPage
{
DetailPage detailPage;
MenuPage masterPage;
NavigationPage detailNavigationPage;
publicDashboardPage ()
{
detailPage = new DetailPage ();
detailNavigationPage=new NavigationPage(detailPage); // Navigation Page as parent for Detail Page.
Detail = detailNavigationPage;
masterPage= new MenuPage(){Icon="ic_settings.png"}; // ic_settings.png willbe rendered as Menu Icon.
Master = masterPage;
}
}
Solution 2:
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:
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:
publicApp()
{
DependencyService.Register<IMessageService, MessageService>();
DependencyService.Register<INavigationService,NavigationService>();
InitializeComponent();
MainPage = new NavigationPage(new MasterDetail());
MercaFacil.App.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(new LoginView()));
}
When the login is successful simply called the PopModalAsync()
method
Solution 3:
By setting the icon of your Master page you should get the image you supply as a button in the navigationbar.
Try someting like this in your MyMasterDetailpage
publicclassMyMasterDetailpage: MasterDetailPage
{
publicMyMasterDetailpage()
{
Detail = new NavigationPage (new Page());
Master = new MenuPage () {
Title = "Title",
Icon = (Device.OS == TargetPlatform.iOS) ? "hamburgermenuicon.png" : null
};
}
}
Solution 4:
If you are pushing the MasterDetailPage using the PushModalAsync then navigation bar will not be shown as it will open the page as a Modal in fullscreen mode. If you push the page as :
await Navigation.PushAsync(new MyMasterDetailPage());
then u will get a back button on the navigation bar clicking it will move you backward to the page before. So your hamburger icon will not be visible.
The option is to set your MasterDetailPage as your MainPage
App.Current.MainPage = new MyMasterDetailPage();
If you want your Page which was added before the MasterDetailPage you can override the OnBackPressed() method in your android activity and push your page in the navigation stack and Pop your current MasterDetailpage.
Post a Comment for "Missing Menu Button On Masterdetailpage When Assigning App.mainpage"