uno: NavigationView - Android - unable to select first menuitem after selecting Settings item

Current behavior

When selecting the navigationview settings item and then selecting the top menu item nothing happens and the ItemInvoked is not fired on Android. If first selecting the settings item and then the second menu item everything works as expected.

Expected behavior

When selecting the navigationview settings item and then any menu item the event should be fired on Android as it does on Windows/UWP

How to reproduce it (as minimally and precisely as possible)

  • Start Visual Studio 2019
  • Create new project using Uno Platform App Template

In shared projects mainpage.xaml paste in this:

<Grid>
        <NavigationView ItemInvoked="OnItemInvoked">
            <NavigationView.MenuItems>
                <NavigationViewItem Content="First item"></NavigationViewItem>
                <NavigationViewItem Content="Second item"></NavigationViewItem>
            </NavigationView.MenuItems>
        </NavigationView>
   </Grid>

In mainpage.cs paste in ths:

private void OnItemInvoked(object sender, NavigationViewItemInvokedEventArgs args)
{}
  • Set a breakpoint at OnItemInvoked
  • Make sure that the android project is set as Startup project
  • Debug project
  • Select Settings item
  • Select “First item”

Environment

Nuget Package: Uno.UI 2.2.0

Package Version(s):

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • Windows
  • Build tasks

Visual Studio

  • 2017 (version: )
  • [x ] 2019 (version: )
  • for Mac (version: )

Relevant plugins

  • Resharper (version: )

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 36 (36 by maintainers)

Commits related to this issue

Most upvoted comments

Easiest is to just put a distinctive x:Name on one of the elements in the page, eg <TextBlock x:Name="Page2NavViewContent" Text="Page 2"/>, then call _app.WaitForElement("Page2NavViewContent") in the test.

WaitForElement() will time out and fail the test if the element isn’t there.

Hmmm I think I’ve misunderstood how I to prepare the UI test runs. Running an UI test doesn’t deploy the sample app it self. So if I make changes to the sample app I’ve have to debug it once before running any UI tests again. That’s what threw me off.

Implemented the fix: return index == -1 ? null : MaterializedContainers.FirstOrDefault(container => Equals(IndexFromContainer(container), index));

On android it worked like a charm. When trying to build the entire solution I get

Generation failed: System.AggregateException: One or more errors occurred. —> System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.

So it’s time to get the newly acquired 16 GB RAM installed.