xamarin/Xamarin.Forms

[Bug] NavigationStack's first page is null and page can not be extracted form shell

Open

#6,681 opened on Jun 27, 2019

 (9 comments) (7 reactions) (0 assignees)C# (1,926 forks)batch import
a/shell :shell:e/3 :clock3:help wantedt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

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.

NavigationProblemSample.zip

Steps to Reproduce

  1. Create a Xamarin 4 shell project with two bottom bars which contain a ListView each.
  2. Push a new Page onto the NavigationStack.
  3. Pop the page.

Expected Behavior

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.

Actual Behavior

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.

Basic Information

  • Version with issue: 4.0.0.540366
  • Last known good version: -
  • IDE: Visual Studio 2019 16.1.3
  • Platform Target Frameworks:
    • Android: 9.0
  • Android Support Library Version: 28.0.0.1
  • Nuget Packages: Xamarin.Forms, Xamarin.Essentials

Contributor guide