xamarin/Xamarin.Forms

[Android] Adding both TapGestureRecognizer and ContextActions to ViewCell will result in ContextActions not responding

オープン

#1,932 opened on 2018/02/20

 (20 件のコメント) (0 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
a/gestures 🖖a/listviewe/6 :clock6:help wantedp/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

Description

When working with ViewCells, adding ContextAction by itself will result in a successful build and expected functionality. However when both a TapGestureRecognizer and ContextActions is set on the same ViewCell, only the TapGestureRecognizer will respond and ContextActions no longer work.

A previous bug has been reported but apparently resolved:

https://bugzilla.xamarin.com/show_bug.cgi?id=46363

Steps to Reproduce

  1. Create a ViewCell with TapGestureRecognizer and ContextAction as so:

The following is a simple example that demonstrates the issue:

public class TableViewCellIssuePage : ContentPage
    {
        #region Constructors
        public TableViewCellIssuePage()
        {
           TapGestureRecognizer tap = new TapGestureRecognizer();
            ViewCell viewCell = new ViewCell()
            {
                View = new Label() { Text = "Cell" }
            };

            viewCell.ContextActions.Add(new MenuItem() { Text = "Never Shows" });

            // If you remove this gesture recognizer then the context action will work.
            viewCell.View.GestureRecognizers.Add(tap);

            this.Content = new StackLayout()
            {
                Children =
                {
                    new TableView()
                    {
                        Root = new TableRoot()
                        {
                            new TableSection()
                            {
                                viewCell
                            }
                        }
                    }
                }
            };
        }
        #endregion
    }

  1. Build and deploy application to Android or iOS Emulator
  2. Notice how long press does no respond while TapGestureRecognizer is. See commented code above to remove GestureRecognizer to have ContextActions work again.

Expected Behavior

Both TapGestureRecognizer and ContextActions should respond when both being added to a single ViewCell.

Actual Behavior

ContextActions do not respond when adding a TapGestureRecognizer to the same ViewCell.

Basic Information

Microsoft Visual Studio Enterprise 2017 Version 15.5.4 VisualStudio.15.Release/15.5.4+27130.2024 Microsoft .NET Framework Version 4.7.02556

Installed Version: Enterprise

Xamarin 4.8.0.757 (7f9ec2a) Xamarin.Android SDK 8.1.3.0 (HEAD/ef47226b7) Xamarin.iOS and Xamarin.Mac SDK 11.6.1.2 (6857dfc)

NUGET: Xamarin.Forms - 2.5.0.280555

コントリビューターガイド