0

I have a shell flyout menu on my maui app and I use routing on code to navigate as well.

<!--On AppShell.xaml-->
<ShellContent 
    Title="My Page"
    ContentTemplate="{DataTemplate views:MyPage}" />
//on AppShell.xaml.cs
Routing.RegisterRoute(nameof(MyPage), typeof(MyPage));
//On MyPageViewModel
//Command using CommunityToolKit.MVVM
[RelayCommand]
async Task GoToMyPage()
{
    await Shell.Current.GoToAsync(nameof(MyPage));
}

If I navigate via the menu, the menu behavior is as expected the selected menu item changes to the current page but when I navigate via the code the selected menu remains the previous page.

I would like to keep the navigation stack to allow the user to return to the previous page via the return button but I would also like to change the selected menu item to the current page, both to show the current page highlighted but also to allow the user to select that initial page via the menu for navigation.

For reference on the following explanation lets imagine 3 pages, InitialPage MyPage RandomPage:

Currently if I already navigated via code from InitialPage to MyPage, and try to select the InitialPage on the menu its not responding because it is selected and if I change to RandomPage via the menu, and change again to InitialPage it brings me to MyPage (because I assume is the last on the navigation stack).

I want when I first change to MyPage that the selected item on the menu reflects that change of page, and when I change back to InitialPage via the menu I want to navigate to the InitialPage.

I don't care if the navigation stack is reseted upon returning to the InitalPage or if the navigation is added to it such as: { InitialPage, MyPage, InitialPage}.

What should I change, or add, to achieve what I explained above?

Barreto
  • 374
  • 2
  • 14
  • Does this answer your question? [How to change the color of the selected item in flyout menu?](https://stackoverflow.com/questions/67747958/how-to-change-the-color-of-the-selected-item-in-flyout-menu) – Himanshu Dwivedi May 07 '23 at 16:05
  • no, I dont want to simply "Change color" I want to change the logic behind the flyout navigation. this is not a style question. – Barreto May 07 '23 at 16:57
  • Sorry, I couldn't reproduce this problem. If it is convenient for you, could you please post a basic demo so that we can test on our side? – Jessie Zhang -MSFT May 26 '23 at 07:44

0 Answers0