Xamarin隐藏汉堡包菜单栏

时间:2018-05-30 13:36:54

标签: c# xamarin xamarin.forms

我试图将酒吧隐藏在汉堡菜单中,只保留Uber App之类的图标按钮。

enter image description here

我有一个默认的母版页详细结构,我尝试了多种解决方案:

1 - 在App.xaml中

<ResourceDictionary>           
        <Style TargetType="NavigationPage">
            <Setter Property="BarBackgroundColor" Value="Transparent"/>
            <Setter Property="BarTextColor" Value="Red"/>
        </Style>              
</ResourceDictionary>

2 - MasterDetailPageRenderer

public class CustomMasterDetailRenderer : MasterDetailPageRenderer
{
    public CustomMasterDetailRenderer(Android.Content.Context context):base(context)
    {

    }
    protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
    {
        base.OnLayout(changed, left, top, right, bottom);          
        var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
        if (toolbar != null)
        {               
            toolbar.SetBackgroundColor(Android.Graphics.Color.Argb(0, 0, 0, 0));
        }            
    }
}

不幸的是,得到了这个结果:

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用(XAML)隐藏此页面中的导航栏:

NavigationPage.HasNavigationBar="False"

使用点击手势识别器添加您自己的汉堡图标以处理菜单可见性:

MasterDetailPage masterDetailRootPage = (MasterDetailPage)Application.Current.MainPage;
masterDetailRootPage.IsPresented = true;