Xamarin 导航栏隐藏汉堡菜单 [英] Xamarin Navigation Bar Hide Hamburger Menu

查看:65
本文介绍了Xamarin 导航栏隐藏汉堡菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要隐藏某些页面上的汉堡菜单,但仍会在导航栏中显示信息.我不知道有什么方法可以做到这一点.

另外,我需要导航栏固定在屏幕顶部,但是当键盘弹出时它会被切断.

我该怎么办?

解决方案

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
        }

这篇关于Xamarin 导航栏隐藏汉堡菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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