.NET MAUI MacCatalyst Menu Bar items count problem

121 views Asked by At

For my .NET MAUI app, i need to use a menu bar for desktop environments (WinUI and MacCatalyst)

I have 80+ MenuFlyoutItem elements. That works good for windows. But for MacCatalyst it is limited to 50 items as related Microsoft Document describes. (throws an exception if exceeds)

https://learn.microsoft.com/en-us/dotnet/maui/user-interface/menu-bar

But document says;

Additional menu items, beyond the 50 limit, can be added to a menu bar by adding the following code to your AppDelegate class:

[Export("MenuItem50: ")]
internal void MenuItem50(UICommand uICommand)
{
    uICommand.SendClicked();
}

So I added that piece of code to Platforms/MacCatalyst/AppDelegate.cs like;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{

    [Export("MenuItem50: ")]
    internal void MenuItem50(UICommand uICommand)
    {
        uICommand.SendClicked();
    }
    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

App builds successfully with this code, but flashes and exits at startup with no error message when it is ran

Am i missing something here?

Regards

0

There are 0 answers