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
Solution 1:
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
}
Post a Comment for "Xamarin Navigation Bar Hide Hamburger Menu"