xamarin/Xamarin.Forms

No selection feedback for Shell MenuItems

Ouverte

#5 816 ouverte le 5 avr. 2019

 (9 commentaires) (0 réaction) (0 personne assignée)C# (1 926 forks)batch import
a/shell :shell:e/3 :clock3:help wantedp/Androidp/iOS 🍎t/bug :bug:up-for-grabs

Métriques du dépôt

Stars
 (5 644 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

Description

Unlike ShellItems, MenuItems don't get selection feedback or indicate selected state after being tapped. The flyout is also not automatically hidden after selection when FlyoutBehavior is set to Flyout.

Steps to Reproduce

  1. Create new project based on Xaramin shell template
  2. Modify default shell page to enable items in flyout menu
<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
       xmlns:local="clr-namespace:XamShellApp.Views"
       RouteScheme="app"
       Route="xamshellapp"
       FlyoutBehavior="Flyout"
       Title="XamShellApp"
       x:Class="XamShellApp.AppShell"
       x:Name="MyShell">

    <!-- Your Pages -->
    <Shell.Items>
        <ShellItem Title="Items 1">
            <ShellSection>
                <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
            </ShellSection>
        </ShellItem>
        <ShellItem Title="Items 2">
            <ShellSection>
                <ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
            </ShellSection>
        </ShellItem>
    </Shell.Items>
    <Shell.MenuItems>
        <MenuItem BindingContext="{x:Reference MyShell}" Command="{Binding AboutCommand}" Text="About" />
    </Shell.MenuItems>
</Shell>

Note: Binding context on MenuItem must be explicitly set until bug #5707 is fixed.

  1. Add Command to handle menu selection
using Xamarin.Forms;
using XamShellApp.Views;

namespace XamShellApp
{
    public partial class AppShell : Shell
    {
        public Command AboutCommand { get; }

        public AppShell()
        {
            Routing.RegisterRoute("about", typeof(AboutPage));
            AboutCommand = new Command(() =>
            {
                GoToAsync("app:///xamshellapp/about");
                FlyoutIsPresented = false;
            });

            BindingContext = this;
            InitializeComponent();
        }
    }
}

Expected Behavior

Selecting a menu items should behave the same as selecting a ShellItem.

Actual Behavior

Selecting a menu item:

  • Has no visual feedback when tapped
  • Does not maintain selected state like ShellItem
  • Does not automatically hide flyout after selection

Basic Information

  • Version with issue: v4.0.0.204370-pre8
  • Last known good version: N/A
  • IDE: v16.0.0
  • Platform Target Frameworks:
    • Android: v9.2.0.5 SDK
    • iOS: Not tested (but expect same issue)

Guide contributeur