-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ShouldShowToolbarButton() override on FlyoutPage not working #15111
Comments
If there is a known workaround to remove the burger button, i would like to know. |
While migrating an existing app from Xamarin.Forms to MAUI, I came across this bug as well. I was able to test on Android and iOS:
No workaround known to me. |
Found a pretty ugly workaround to hide the icon in the handler (for Android): public class ToolbarHandler : Microsoft.Maui.Handlers.ToolbarHandler
{
protected override void ConnectHandler( MaterialToolbar platformView )
{
( VirtualView as Toolbar ).PropertyChanged += ToolbarHandler_PropertyChanged;
base.ConnectHandler( platformView );
}
protected override void DisconnectHandler( MaterialToolbar platformView )
{
( VirtualView as Toolbar ).PropertyChanged -= ToolbarHandler_PropertyChanged;
base.DisconnectHandler( platformView );
}
private void ToolbarHandler_PropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
{
if( sender is not Toolbar toolbar || !toolbar.DrawerToggleVisible )
{
return;
}
// This property doesn't invoke a property changed.
// Somewhere in the source, this is being set to 'true'
// and doesn't reference ShouldShowToolbarButton().
// There might be somewhere better to call this but this gets the job done.
toolbar.DrawerToggleVisible = false;
}
} I couldn't find anywhere better to call this, and this seems to catch it in my use case. It isn't the best solution because you're assuming that there is a property change after |
Verified this on Visual Studio Enterprise 17.8.0 Preview 2.0. Repro on Android 13.0-API33(8.0.0-rc.1), not repro on iOS 16.4 with below Project: |
@samhouts I just tested if this is fixed in version 8.0.14 but it seems the issue still is there. |
Seems to be working on main @schinkenwuerfel : class App : Application
{
protected override Window CreateWindow(IActivationState? activationState)
{
// To test shell scenarios, change this to true
bool useShell = false;
if (!useShell)
{
var flyout = new Flyout();
flyout.Flyout = new ContentPage { Title = "Flyout" };
flyout.Detail = new NavigationPage(new MainPage());
return new Window(flyout);
}
else
{
return new Window(new SandboxShell());
}
}
class Flyout : FlyoutPage
{
public override bool ShouldShowToolbarButton()
{
return false;
}
}
} I have a hunch that the fix made only fixes when the root page is a NavigationPage. |
Description
Im trying to have a custom navigation bar.
I have a FlyoutPage that sets a custom Detail (a NavigationPage that contains a TabbedPage). In the tabbed page constructor i load a custom view to my navigationPage title view, wich works correctly, but since im using a FlyoutPage the burger 'Open Flyout' button is still present.
After looking around i found that i could override the ShouldShowToolbarButton() in my FlyoutPage to make it always return false, thus making it not show the button, but this does not work. Im doing my testing on Android.
Steps to Reproduce
1- Create new .net MAUI app.
2- Create new FlyoutPage
3- Load a custom ContentPage as Flyout in the constructor (example 1)
4- Load a custom TabbedPage inside a NavigationPage as Detail (emaple 1)
5- Load a custom View as TitleView in the TabbedPage
NavigationPage.SetTitleView(this, new NewContent2());
6- Override the
ShouldShowToolbarButton
method in the FlyoutPage so it always returns false.Link to public reproduction project repository
https://github.com/GODston/Public
Version with bug
8.0 previews
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 13 API 33
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: