简体   繁体   中英

Xamarin Navigation Bar Hide Hamburger Menu

I need to hide the hamburger menu on certain pages but still display information in then navbar. I don't know of any way to accomplish this.

Also, I need the navbar to stay fixed to the top of the screen but it's getting cut off when the keyboard pops up.

How can I go about this?

FlyoutPage.ShouldShowToolbarButton method is used to determine whether to show/hide hamburger icon, and it is triggered every time when selecting pages.

We can define a bool field,change its value when directing to specific pages.

FlyoutPage

 public override bool ShouldShowToolbarButton()
        {
            return showIcon;
        }

        private bool showIcon = true;

        private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as FlyoutPage1FlyoutMenuItem;
            if (item == null)
                return;

            var page = (Page)Activator.CreateInstance(item.TargetType);
            page.Title = item.Title;

            Detail = new NavigationPage(page);
            IsPresented = false;

            FlyoutPage.ListView.SelectedItem = null;


            //add this logic
            showIcon = (item.Id == 1) ? false : true;   //only the second page do not show hamburger icon
        }

在此处输入图像描述

在此处输入图像描述 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM