xamarin/Xamarin.Forms

No selection feedback for Shell MenuItems

开放

#5,816 创建于 2019年4月5日

 (9 条评论) (0 个反应) (0 位负责人)C# (1,926 个派生)batch import
a/shell :shell:e/3 :clock3:help wantedp/Androidp/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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)

贡献者指南