MasterDetailPage.ShouldShowToolbarButton() is not taken into account

Hey guys,
I'm currently trying to hide the burger/menu icon on some views, when using MasterDetailPage.
I've found and overwritten the method "ShouldShowToolbarButton()" in the MasterDetailPage class.
Sadly, nothing changed, so I took a look into the source code of Xamarin.Forms.

In the MasterDetailPageRenderer for Android/AppCompat I've found the method UpdateToolbar().
Here is a part of it:

    bool isNavigated = ((INavigationPageController)Element).StackDepth > 1;
    bar.NavigationIcon = null;

    if (isNavigated)
    {
        if (toggle != null)
        {
            toggle.DrawerIndicatorEnabled = false;
            toggle.SyncState();
        }

        if (NavigationPage.GetHasBackButton(Element.CurrentPage))
        {
            var icon = new DrawerArrowDrawable(activity.SupportActionBar.ThemedContext);
            icon.Progress = 1;
            bar.NavigationIcon = icon;
        }
    }
    else
    {
        if (toggle != null)
        {
            toggle.DrawerIndicatorEnabled = true;
            toggle.SyncState();
        }
    }

As you can see, ShouldShowToolbarButton() is absolutely not taken into account.
Wouldn't it be better to change the code to something like:

bool isNavigated = ((INavigationPageController)Element).StackDepth > 1;
bar.NavigationIcon = null;

if (isNavigated)
{
    if (toggle != null)
    {
        toggle.DrawerIndicatorEnabled = false;
        toggle.SyncState();
    }

    if (NavigationPage.GetHasBackButton(Element.CurrentPage))
    {
        var icon = new DrawerArrowDrawable(activity.SupportActionBar.ThemedContext);
        icon.Progress = 1;
        bar.NavigationIcon = icon;
    }
}
else
{
    if (toggle != null)
    {
        toggle.DrawerIndicatorEnabled = _masterDetailPage.ShouldShowToolbarButton();
        toggle.SyncState();
    }
}

Thank you and have a nice day,
George

Sign In or Register to comment.