Bug 24273 - Cell.OnLongPressed() not called in Android
Summary: Cell.OnLongPressed() not called in Android
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-11-05 04:10 UTC by Sergio Paganoni
Modified: 2015-02-05 05:54 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Sergio Paganoni 2014-11-05 04:10:59 UTC
I'm pretty sure this was working until a couple of weeks ago.

For some reason, the method OnLongPressed is not getting called anymore when you long press the Cell of a ListView using Android.

Same code works for WP flawlessly. 

Tested on Android (emulators) version 4.4.2 and 4.1.1

Sample code-snippet to reproduce the problem:

public class MyPage : ContentPage 
  var listView = new ListView
      BindingContext = _myViewModel.Drafts,
      ItemsSource = _myViewModel.Drafts,
      ItemTemplate = new DataTemplate(typeof(CustomCell)),
      RowHeight = 65
  Content = listView;
public class CustomCell : ViewCell
    public CustomCell()
        // ... defines some layout (no gesture/listener whatsoever)
        View = viewLayout;

    protected override void OnLongPressed()
        Debug.Info(GetType(),"This is never triggered!");

--- My environment ---
Xamarin 3.7.203
Developing on Visual Studio 2013 on Windows 8.1 Pro
Comment 1 Arpit Jha 2014-11-05 07:12:38 UTC
We have checked this issue and observed that OnLongPressed() event not working.
We tried following steps to reproduce it.
1.Create a XAmarin.form application.
2.Add a class (Mypage.cs) and did some code in it.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace Bug24273
    public class ListButton : Button { }

    class Mypage : ContentPage

        public Mypage()
            var listView = new ListView { RowHeight = 65 };
            listView.ItemsSource = new string[] { "First", "Secound", "third", "fourth", "Fifth" };
            listView.ItemTemplate = new DataTemplate(typeof(CustomCell));
            Content = new StackLayout
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children = { listView }



    public class CustomCell : ViewCell
        public CustomCell()
            var label1 = new Label { Text = "Label 1", Font = Font.SystemFontOfSize(20) };
            label1.SetBinding(Label.TextProperty, new Binding("."));

            var label2 = new Label { Text = "Label 2", Font = Font.SystemFontOfSize(NamedSize.Small) };


            View = new StackLayout
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Padding = new Thickness(15, 5, 5, 15),
                Children = {
					new StackLayout {
						Orientation = StackOrientation.Vertical,
						Children = { label1, label2 }

        protected override void OnLongPressed()
            Debug.WriteLine("This is never triggered!");

3.Run the application.

We observed that unable to call OnLongPressed event on listview item long press click.

Please let me know are you getting same behavior?

Environment Info:
Microsoft Visual Studio Professional 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Xamarin (8ca7d11db8a6f874c6cd2de6d9ca0f511867ce91)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (5474129af31e9d3a86cb7482c7c5c7a30ad315f1)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS (209abebbd8f1a292d042420edb45fa5fbd3f017b)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 2 Sergio Paganoni 2014-11-05 11:29:23 UTC
Since the example is pretty much the same as the one provided by me, I'd say yes, same behaviour.
Comment 3 Jason Smith [MSFT] 2015-02-05 05:54:28 UTC
OnLongPressed has been removed as it never worked and has been replaced by ContextActions