We would like to extract the currently active view out of the shell.
The exact situation is that we have two bottom tabs which navigate to different views. Both views contain a ListView, which execute PushAsync on selecting an item. When calling PopAsync we previously used OnAppearing for reloading the data, but that is not being called anymore.
Instead we found out that, on every type of navigation, OnNavigated(ShellNavigatedEventArgs) in the shell is being called. We tried to extract the active view out of Shell.Current, but didn't manage to do so.
The first page on the NavigationStack contains the page navigated to by the bottom tab bar. BaseShellItem.Page/ShellSection.PresentedPage property should be visible to extract the active view.
The first page on the NavigationStack is null after navigating via the bottom tab bar. In Addition, BaseShellItem.Page/ShellSection.PresentedPage should be visible properties to extract the active view.
While this is obviously a bug and needs to be fixed, temporary workaround to get first page is:
((IShellContentController) AppShell.CurrentItem.CurrentItem.CurrentItem).Page
@viktorszekeress the suggestion you provided does work to get the first item, but does not work when you attempt to remove the first page.
If you call Shell.Current.Navigation.RemovePage(firstPage) the call will execute, but the navigation stack will not remove the first item.
I am facing same issue. I wanna get the first page every time, so I can InserPageBefore() my error page so then I should PopToRootAsync() and show fatal error page. But with this bug, when I get the first page from the stack it is null so I can not do InsertPageBefore()
Same issue.
Because of this bug it is impossible to structure a Login cycle going then to insert the root page of the application after Login.