Page changing using menu bar stops command in menu bar from working
See original GitHub issueDescription
Since MenuBarItem did not had command binding option, I chose MenuFlyoutItem. But when doing navigation in it, it stops command in menu bar from working. It doesn’t crash but it stops working.
Steps to Reproduce
Add to MainPage.xaml:
<ContentPage.MenuBarItems>
<MenuBarItem Text="Pages">
<MenuFlyoutItem Text="Page1"
Command="{Binding TapCommand}"/>
</MenuBarItem>
</ContentPage.MenuBarItems>
Add to MainViewModel.cs:
[RelayCommand]
async Task Tap()
{
await Shell.Current.GoToAsync(nameof(Page1));
}
Add to Page1.xaml
<ContentPage.MenuBarItems>
<MenuBarItem Text="Options">
<MenuFlyoutItem Text="GoBack"
Command="{Binding GoBackCommand}"/>
<MenuFlyoutItem Text="Exit"
Command="{Binding ExitCommand}"/>
</MenuBarItem>
</ContentPage.MenuBarItems>
Add to Page1ViewModel.cs
[RelayCommand]
public static void Exit()
{
System.Environment.Exit(0);
}
[RelayCommand]
async Task GoBack()
{
await Shell.Current.GoToAsync("..");
}
As usual add to AppShell.xaml.cs
Routing.RegisterRoute(nameof(Page1), typeof(Page1));
and add to MauiProgram.cs
builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<MainViewModel>();
builder.Services.AddTransient<Page1>();
builder.Services.AddTransient<Page1>();
Link to public reproduction project repository
https://github.com/HimanshuBansal112/NetMauiIssue
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
I was not able test on other platforms
Affected platform versions
Windows 11(Build 22621.1344)
Did you find any workaround?
No
Relevant log output
N/A
Issue Analytics
- State:
- Created 6 months ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to change page through my menu bar methods in ...
every tutorial I find is through the buttons, and only the buttons.. I am using python 3.6, with tkinter . import tkinter as...
Read more >How to troubleshoot a frozen menu bar
Doing this should spur the menu bar to change, causing the system to re-draw it and perhaps making it full and functional again....
Read more >Why Did My Mac Menu Bar Disappear? - YouTube
https://macmost.com/e-2769 If you notice that the Menu Bar at the top of your screen is missing, it is probably because you are using...
Read more >Change Desktop & Dock settings on Mac
On your Mac, use Desktop & Dock settings to change the appearance of the Dock, and to select items to show in the...
Read more >How to customize the Menu Bar on Mac
Want to edit Mac menu bar? See the best tips to rearrange, remove, and stack icons in your menu bar to keep all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seems like the flyout items’ binding context is getting lost during the navigation process. For me I have ‘fixed’ the issue like this:
What vrishe proposed is a workaround, not a fix. Fix mean it should have work correctly as intended, no work around needed.