locked
how can i recognize long press gesture in xamarin forms RRS feed

  • Question

  • User79695 posted

    Hi,

    Could you please let me know how can i recognize long press gesture in xamarin forms application. Also let me know how can i implement left & right swipe

    Thanks & Regards, Siva

    Wednesday, November 5, 2014 6:46 AM

Answers

  • User81742 posted

    The latest version of Xamarin-Forms-Lab has a wrapper class that you can use to enable gesture support on any View derived object. Enabling Gestures is as simple as :

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:lc="clr-namespace:Xamarin.Forms.Labs.Controls;assembly=Xamarin.Forms.Labs"
                 xmlns:lb="clr-namespace:Xamarin.Forms.Labs.Behaviors;assembly=Xamarin.Forms.Labs"             
                           x:Class="Teachers.Pages.Scratch">
      <StackLayout>
        <lc:GesturesContentView>
          <StackLayout>
            <Label Text="Gesture me NOW!">
              <lb:Gestures.Interests>
                <lb:GestureInterests>
                  <lb:GestureInterest GestureType="SingleTap" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Right" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                </lb:GestureInterests>
              </lb:Gestures.Interests>
            </Label>
            <Label Text="I do nothing"/>
          </StackLayout>
        </lc:GesturesContentView>
      </StackLayout>
    </ContentPage>
    

    Then in your viewmodel:

    public class MyViewModel
        {
            MyViewModel()
                {
                //g is a GestureResult and x is the GestureParameter
                    DumpParam = new RelayGesture((g,x)=>Debug.WriteLine("DUMPING {0} from a {1}[{2}]",x,g.GestureType,g.Direction));
    
                }
    
                public RelayGesture DumpParam { get; set; }  
        }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, November 5, 2014 12:26 PM

All replies

  • User81742 posted

    The latest version of Xamarin-Forms-Lab has a wrapper class that you can use to enable gesture support on any View derived object. Enabling Gestures is as simple as :

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:lc="clr-namespace:Xamarin.Forms.Labs.Controls;assembly=Xamarin.Forms.Labs"
                 xmlns:lb="clr-namespace:Xamarin.Forms.Labs.Behaviors;assembly=Xamarin.Forms.Labs"             
                           x:Class="Teachers.Pages.Scratch">
      <StackLayout>
        <lc:GesturesContentView>
          <StackLayout>
            <Label Text="Gesture me NOW!">
              <lb:Gestures.Interests>
                <lb:GestureInterests>
                  <lb:GestureInterest GestureType="SingleTap" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Right" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                </lb:GestureInterests>
              </lb:Gestures.Interests>
            </Label>
            <Label Text="I do nothing"/>
          </StackLayout>
        </lc:GesturesContentView>
      </StackLayout>
    </ContentPage>
    

    Then in your viewmodel:

    public class MyViewModel
        {
            MyViewModel()
                {
                //g is a GestureResult and x is the GestureParameter
                    DumpParam = new RelayGesture((g,x)=>Debug.WriteLine("DUMPING {0} from a {1}[{2}]",x,g.GestureType,g.Direction));
    
                }
    
                public RelayGesture DumpParam { get; set; }  
        }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, November 5, 2014 12:26 PM
  • User79695 posted

    Thank you very much Charles Horan. I will check above option..

    Thursday, November 6, 2014 5:29 AM
  • User57191 posted

    Any way we can do this programmatically, without XAML?

    Thursday, December 11, 2014 9:59 AM
  • User57869 posted

    @Kumar.1560 @Shax @CharlesHoran

    You could also use MR.Gestures to handle all the touch gestures. This not only supports views, but also all kinds of cells, layouts and the ContentPage.

    The XAML would look like this

    ```

             Padding="50"
    
             TappingCommand="{Binding TappingCommand}"
             TappedCommand="{Binding TappedCommand}"
             DoubleTappedCommand="{Binding DoubleTappedCommand}"
             LongPressingCommand="{Binding LongPressingCommand}"
             LongPressedCommand="{Binding LongPressedCommand}"
             PanningCommand="{Binding PanningCommand}"
             PannedCommand="{Binding PannedCommand}"
             SwipedCommand="{Binding SwipedCommand}"
             PinchingCommand="{Binding PinchingCommand}"
             PinchedCommand="{Binding PinchedCommand}"
             RotatingCommand="{Binding RotatingCommand}"
             RotatedCommand="{Binding RotatedCommand}"
             >
    

    ```

    And in code

            var box1 = new MR.Gestures.BoxView { Color = Color.Red };
            box1.LongPressing += (s, e) => { Console.WriteLine("CodePage: Red LongPressing"); };
            box1.LongPressed += (s, e) => { Console.WriteLine("CodePage: Red LongPressed"); };
    

    More info on MR.Gestures can be found at http://www.mrgestures.com/ Just check out the sample app https://github.com/MichaelRumpler/GestureSample. The code samples above are just copied from there.

    Thursday, February 12, 2015 10:17 AM
  • User57191 posted

    @MichaelRumpler thanks for the info. However it would have been fair if you've mentioned that

    • your example requires 3rd party component
    • component is not free
    • you're the author

    Regards.

    Tuesday, February 17, 2015 11:26 AM
  • User57869 posted

    @Shax

    All true and all that info is on the website.

    If you want to do it yourself, you could also start from http://arteksoftware.com/gesture-recognizers-with-xamarin-forms/ and write custom renderers with your native gesture recognizers attached. But that approach will definitely cost you more than the EUR 10,- for MR.Gestures.

    Tuesday, February 17, 2015 12:12 PM
  • User31414 posted

    @Shax

    you can use the following code to add gestures programmatically:

    public class MyPage : ContentPage {

        public MyPage()
        {
            var vm = new MyViewModel();
    
            var stackLayout = new StackLayout()
            {
                Children =
                {
                    new Label()
                    {
                        Text = "Hello World"
                    }
                }
            };
    
            stackLayout.SetValue(Gestures.InterestsProperty, new GestureCollection()
            {
                new GestureInterest()
                {
                    GestureType = GestureType.LongPress,
                    GestureCommand = vm.CopyCommand,
                    GestureParameter = vm.LabelText 
                }
            });
    
            var gc = new GesturesContentView {ExcludeChildren = false, Content = stackLayout};
    
    
            Content = new StackLayout
            {
                Children = {
                    gc
                }
            };
         }
    }
    
    Thursday, April 23, 2015 9:51 AM
  • User159623 posted

    Here's how to programmatically make a custom renderer to recognize the UILongPressGestureRecognizer in iOS.

    In this sample I am implementing the UILongPressGestureRecognizer on an Image in Xamarin.Forms.

    Extend Image in Xamarin.Forms PCL ``` using System; using Xamarin.Forms;

    namespace SampleApp { public class ImageWithLongPressGesture : Image { public void HandleLongPress () { //Handle LongPress } } } ```

    Custom Renderer in iOS Project ``` using System;

    using UIKit;

    using SampleApp; using SampleApp.iOS;

    using Xamarin.Forms; using Xamarin.Forms.Platform.iOS;

    [assembly:ExportRenderer (typeof(ImageWithLongPressGesture), typeof(LongPressGestureRecognizerImageRenderer))] namespace SampleApp.iOS { public class LongPressGestureRecognizerImageRenderer : ImageRenderer { ImageWithLongPressGesture view;

        public LongPressGestureRecognizerImageRenderer ()
        {
            this.AddGestureRecognizer (new UILongPressGestureRecognizer ((longPress) => {
                if (longPress.State == UIGestureRecognizerState.Began) {
                    view.HandleLongPress();
                }
            }));
        }
    
        protected override void OnElementChanged (ElementChangedEventArgs<Image> e)
        {
            base.OnElementChanged (e);
    
            if (e.NewElement != null)
                view = e.NewElement as ImageWithLongPressGesture;
        }
    }
    

    } ```

    Tuesday, January 19, 2016 3:22 AM
  • User85684 posted

    @CharlesHoran said: The latest version of Xamarin-Forms-Lab has a wrapper class that you can use to enable gesture support on any View derived object. Enabling Gestures is as simple as :

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:lc="clr-namespace:Xamarin.Forms.Labs.Controls;assembly=Xamarin.Forms.Labs"
                 xmlns:lb="clr-namespace:Xamarin.Forms.Labs.Behaviors;assembly=Xamarin.Forms.Labs"             
                         x:Class="Teachers.Pages.Scratch">
      <StackLayout>
        <lc:GesturesContentView>
          <StackLayout>
            <Label Text="Gesture me NOW!">
              <lb:Gestures.Interests>
                <lb:GestureInterests>
                  <lb:GestureInterest GestureType="SingleTap" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Right" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                </lb:GestureInterests>
              </lb:Gestures.Interests>
            </Label>
            <Label Text="I do nothing"/>
          </StackLayout>
        </lc:GesturesContentView>
      </StackLayout>
    </ContentPage>
    

    Then in your viewmodel:

    public class MyViewModel
        {
            MyViewModel()
              {
              //g is a GestureResult and x is the GestureParameter
                    DumpParam = new RelayGesture((g,x)=>Debug.WriteLine("DUMPING {0} from a {1}[{2}]",x,g.GestureType,g.Direction));
    
              }
    
                public RelayGesture DumpParam { get; set; }  
        }
    

    @CharlesHoran said: The latest version of Xamarin-Forms-Lab has a wrapper class that you can use to enable gesture support on any View derived object. Enabling Gestures is as simple as :

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:lc="clr-namespace:Xamarin.Forms.Labs.Controls;assembly=Xamarin.Forms.Labs"
                 xmlns:lb="clr-namespace:Xamarin.Forms.Labs.Behaviors;assembly=Xamarin.Forms.Labs"             
                         x:Class="Teachers.Pages.Scratch">
      <StackLayout>
        <lc:GesturesContentView>
          <StackLayout>
            <Label Text="Gesture me NOW!">
              <lb:Gestures.Interests>
                <lb:GestureInterests>
                  <lb:GestureInterest GestureType="SingleTap" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                  <lb:GestureInterest GestureType="Swipe" Direction="Right" GestureCommand="{Binding DumpParam}" GestureParameter="{Binding Ready}"/>
                </lb:GestureInterests>
              </lb:Gestures.Interests>
            </Label>
            <Label Text="I do nothing"/>
          </StackLayout>
        </lc:GesturesContentView>
      </StackLayout>
    </ContentPage>
    

    Then in your viewmodel:

    public class MyViewModel
        {
            MyViewModel()
              {
              //g is a GestureResult and x is the GestureParameter
                    DumpParam = new RelayGesture((g,x)=>Debug.WriteLine("DUMPING {0} from a {1}[{2}]",x,g.GestureType,g.Direction));
    
              }
    
                public RelayGesture DumpParam { get; set; }  
        }
    

    I followed same step, but no success. Would you please share your code ?

    Thanks !!

    Friday, September 2, 2016 4:26 AM
  • User274395 posted

    I replaced with it is compiling and running fine but GestureCommand not firing any event on any of the gestures. DumpParam = new RelayGesture((g, x) => Debug.WriteLine("DUMPING {0} from a {1}[{2}]", x, g.GestureType, g.Direction));

    Please help.

    Monday, December 12, 2016 1:19 AM
  • User255679 posted

    @BrandonMinnick said: Here's how to programmatically make a custom renderer to recognize the UILongPressGestureRecognizer in iOS.

    Is there any suggestion for making a custom renderer in Android ?

    Friday, March 31, 2017 12:25 PM
  • User233224 posted

    How can I do a LongPress and then a Swipe like happens when we record an audio on WhatsApp and Facebook Messenger App?

    Also, how it's possible to detect when LongPress is out, when user leaves the button?

    Tuesday, April 11, 2017 3:31 PM
  • User298515 posted

    @BrandonMinnick said: Here's how to programmatically make a custom renderer to recognize the UILongPressGestureRecognizer in iOS.

    In this sample I am implementing the UILongPressGestureRecognizer on an Image in Xamarin.Forms.

    Extend Image in Xamarin.Forms PCL ``` using System; using Xamarin.Forms;

    namespace SampleApp { public class ImageWithLongPressGesture : Image { public event EventHandler LongPressActivated;

      public void HandleLongPress (object sender, EventArgs e)
      {
          //Handle LongPressActivated Event
      }
    

    } } ```

    Custom Renderer in iOS Project ``` using System;

    using UIKit;

    using SampleApp; using SampleApp.iOS;

    using Xamarin.Forms; using Xamarin.Forms.Platform.iOS;

    [assembly:ExportRenderer (typeof(ImageWithLongPressGesture), typeof(LongPressGestureRecognizerImageRenderer))] namespace SampleApp.iOS { public class LongPressGestureRecognizerImageRenderer : ImageRenderer { ImageWithLongPressGesture view;

      public LongPressGestureRecognizerImageRenderer ()
      {
          this.AddGestureRecognizer (new UILongPressGestureRecognizer ((longPress) => {
              if (longPress.State == UIGestureRecognizerState.Began) {
                  view.HandleLongPress(view, EventArgs.Empty);
              }
          }));
      }
    
      protected override void OnElementChanged (ElementChangedEventArgs<Image> e)
      {
          base.OnElementChanged (e);
    
          if (e.NewElement != null)
              view = e.NewElement as ImageWithLongPressGesture;
      }
    

    } } ```

    It looks like you shoul get NullReferenceException when you try to call view.HandleLongPress(view, EventArgs.Empty);

    Sunday, April 23, 2017 4:03 PM
  • User114776 posted

    I was looking for a way to use gestures without writing custom renderers for each control where I want to use the gesture.

    I solved it using the effects:

    here is the Pcl Effect Class:

    public class LongPressedEffect : RoutingEffect
    {
        public LongPressedEffect() : base("MyCompany.LongPressedEffect")
        {
        }
    
        public static readonly BindableProperty CommandProperty = BindableProperty.CreateAttached("Command", typeof(ICommand), typeof(LongPressedEffect), (object)null);
        public static Command GetCommand(BindableObject view)
        {
            return (Command)view.GetValue(CommandProperty);
        }
    
        public static void SetCommand(BindableObject view, bool value)
        {
            view.SetValue(CommandProperty, value);
        }
    
    
        public static readonly BindableProperty CommandParameterProperty = BindableProperty.CreateAttached("CommandParameter", typeof(object), typeof(LongPressedEffect), (object)null);
        public static Command GetCommandParameter(BindableObject view)
        {
            return (Command)view.GetValue(CommandParameterProperty);
        }
    
        public static void SetCommandParameter(BindableObject view, bool value)
        {
            view.SetValue(CommandParameterProperty, value);
        }
    }
    

    and in android project:

    [assembly: ResolutionGroupName("MyCompany")]
    [assembly: ExportEffect(typeof(AndroidLongPressedEffect), "LongPressedEffect")]
    namespace APPiediBus.App.Droid.Framework.Effects
    {
        public class AndroidLongPressedEffect : PlatformEffect
        {
            private bool _attached;
            public AndroidLongPressedEffect()
            {
            }
    
            private static object lockObj = new object();
            protected override void OnAttached()
            {
                //because sometime happens that an effect is detached and immediately after attached (happens in listview), i only attach the handler once
                if (!_attached)
                {
                    lock (lockObj)
                    {
                        if (!_attached)
                        {
                            this.Container.LongClick += Control_LongClick;
                            _attached = true;
                        }
                    }
                }
            }
    
            private void Control_LongClick(object sender, Android.Views.View.LongClickEventArgs e)
            {
                var command = LongPressedEffect.GetCommand(Element);
                if (command != null)
                    command.Execute(LongPressedEffect.GetCommandParameter(Element));
            }
    
            protected override void OnDetached()
            {
            }
    
            protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
            {
                base.OnElementPropertyChanged(args);
            }
    
    
        }
    }
    

    and in xaml I can write this:

    <StackLayout effect:LongPressedEffect.Command="{Binding PhoneCommand}">
        <StackLayout.Effects>
            <effect:LongPressedEffect />
        </StackLayout.Effects>
    </StackLayout>
    

    I can use the effect on other controls (labels...images ecc) without writing any custom renderer. I haven't tested it in ios, but I think that it should work

    Thursday, May 11, 2017 1:55 PM
  • User323491 posted

    @LucaPinasco said: I was looking for a way to use gestures without writing custom renderers for each control where I want to use the gesture.

    I solved it using the effects:

    here is the Pcl Effect Class:

    public class LongPressedEffect : RoutingEffect { public LongPressedEffect() : base("MyCompany.LongPressedEffect") { }

      public static readonly BindableProperty CommandProperty = BindableProperty.CreateAttached("Command", typeof(ICommand), typeof(LongPressedEffect), (object)null);
      public static Command GetCommand(BindableObject view)
      {
          return (Command)view.GetValue(CommandProperty);
      }
    
      public static void SetCommand(BindableObject view, bool value)
      {
          view.SetValue(CommandProperty, value);
      }
    
    
      public static readonly BindableProperty CommandParameterProperty = BindableProperty.CreateAttached("CommandParameter", typeof(object), typeof(LongPressedEffect), (object)null);
      public static Command GetCommandParameter(BindableObject view)
      {
          return (Command)view.GetValue(CommandParameterProperty);
      }
    
      public static void SetCommandParameter(BindableObject view, bool value)
      {
          view.SetValue(CommandParameterProperty, value);
      }
    

    }

    and in android project:

    [assembly: ResolutionGroupName("MyCompany")] [assembly: ExportEffect(typeof(AndroidLongPressedEffect), "LongPressedEffect")] namespace APPiediBus.App.Droid.Framework.Effects { public class AndroidLongPressedEffect : PlatformEffect { private bool _attached; public AndroidLongPressedEffect() { }

          private static object lockObj = new object();
          protected override void OnAttached()
          {
              //because sometime happens that an effect is detached and immediately after attached (happens in listview), i only attach the handler once
              if (!_attached)
              {
                  lock (lockObj)
                  {
                      if (!_attached)
                      {
                          this.Container.LongClick += Control_LongClick;
                          _attached = true;
                      }
                  }
              }
          }
    
          private void Control_LongClick(object sender, Android.Views.View.LongClickEventArgs e)
          {
              var command = LongPressedEffect.GetCommand(Element);
              if (command != null)
                  command.Execute(LongPressedEffect.GetCommandParameter(Element));
          }
    
          protected override void OnDetached()
          {
          }
    
          protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
          {
              base.OnElementPropertyChanged(args);
          }
    
    
      }
    

    }

    and in xaml I can write this:

    I can use the effect on other controls (labels...images ecc) without writing any custom renderer. I haven't tested it in ios, but I think that it should work

    Hi All,

    Sorry to bring up an old thread, I am trying to implement the above in a test app but have issues with: “The name ‘LongPressedEffect’ does not exist in the current context’ in the Android files. Using Visual Studio 2017 CE. I would be grateful of any pointers in the right direction if possible.

    Regards Juno.

    Friday, January 12, 2018 2:33 PM
  • User171749 posted

    @Juno said:

    @LucaPinasco said: I was looking for a way to use gestures without writing custom renderers for each control where I want to use the gesture.

    I solved it using the effects:

    here is the Pcl Effect Class:

    public class LongPressedEffect : RoutingEffect
    {
        public LongPressedEffect() : base("MyCompany.LongPressedEffect")
        {
        }
    
        public static readonly BindableProperty CommandProperty = BindableProperty.CreateAttached("Command", typeof(ICommand), typeof(LongPressedEffect), (object)null);
        public static Command GetCommand(BindableObject view)
        {
            return (Command)view.GetValue(CommandProperty);
        }
    
        public static void SetCommand(BindableObject view, bool value)
        {
            view.SetValue(CommandProperty, value);
        }
    
    
        public static readonly BindableProperty CommandParameterProperty = BindableProperty.CreateAttached("CommandParameter", typeof(object), typeof(LongPressedEffect), (object)null);
        public static Command GetCommandParameter(BindableObject view)
        {
            return (Command)view.GetValue(CommandParameterProperty);
        }
    
        public static void SetCommandParameter(BindableObject view, bool value)
        {
            view.SetValue(CommandParameterProperty, value);
        }
    }
    

    and in android project:

    [assembly: ResolutionGroupName("MyCompany")]
    [assembly: ExportEffect(typeof(AndroidLongPressedEffect), "LongPressedEffect")]
    namespace APPiediBus.App.Droid.Framework.Effects
    {
        public class AndroidLongPressedEffect : PlatformEffect
        {
            private bool _attached;
            public AndroidLongPressedEffect()
            {
            }
    
            private static object lockObj = new object();
            protected override void OnAttached()
            {
                //because sometime happens that an effect is detached and immediately after attached (happens in listview), i only attach the handler once
                if (!_attached)
                {
                    lock (lockObj)
                    {
                        if (!_attached)
                        {
                            this.Container.LongClick += Control_LongClick;
                            _attached = true;
                        }
                    }
                }
            }
    
            private void Control_LongClick(object sender, Android.Views.View.LongClickEventArgs e)
            {
                var command = LongPressedEffect.GetCommand(Element);
                if (command != null)
                    command.Execute(LongPressedEffect.GetCommandParameter(Element));
            }
    
            protected override void OnDetached()
            {
            }
    
            protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
            {
                base.OnElementPropertyChanged(args);
            }
    
    
        }
    }
    

    and in xaml I can write this:

    <StackLayout effect:LongPressedEffect.Command="{Binding PhoneCommand}">
        <StackLayout.Effects>
            <effect:LongPressedEffect />
        </StackLayout.Effects>
    </StackLayout>
    

    I can use the effect on other controls (labels...images ecc) without writing any custom renderer. I haven't tested it in ios, but I think that it should work

    Hi All,

    Sorry to bring up an old thread, I am trying to implement the above in a test app but have issues with: “The name ‘LongPressedEffect’ does not exist in the current context’ in the Android files. Using Visual Studio 2017 CE. I would be grateful of any pointers in the right direction if possible.

    Regards Juno.

    The LongPressedEffect looks like it belongs in the PCL, not the android files. You're using the ExportEffect in the android project to hook it up to the PCL.

    Friday, January 12, 2018 3:38 PM
  • User323491 posted

    Hi Seanyda, Thank you for taking the time to reply. I do have the LongPressedEffect.cs in the PCL, and in the Android project i have AndroidLongPressedEffect.cs. Any more ideas?

    Friday, January 12, 2018 4:09 PM
  • User64943 posted

    LucaPinasco Hi, so I have working the longpress but can a control work with long press and the regular TapGestureRecognizer at the same time? The TapGestureRecognizer stops working when I add the longpress. Any ideas?

    Thursday, April 19, 2018 1:55 PM
  • User117295 posted

    @"BrunoPasquini.7813" said: LucaPinasco Hi, so I have working the longpress but can a control work with long press and the regular TapGestureRecognizer at the same time? The TapGestureRecognizer stops working when I add the longpress. Any ideas?

    I'm also facing same issue. Tapgesture and given solution of adding effect doesn't work together. In my case, I'm using Stacklayout.

    Any fix for such issue?

    Monday, May 14, 2018 5:59 AM
  • User381761 posted

    @Krunal I am also facing the same issue, Long press effect and tap gesture recognizer doesnt work together for android. Any fix for the same. TIA.

    Wednesday, July 17, 2019 6:21 AM
  • User117295 posted

    @SurbhiAroraa Instead of long press, I implemented double tap gesture because of this issue. However, long press effect worked properly for me in iOS.

    Thursday, July 18, 2019 10:32 AM
  • User74 posted

    @Krunal said: @SurbhiAroraa Instead of long press, I implemented double tap gesture because of this issue. However, long press effect worked properly for me in iOS.

    For Android I achieved this will a tap gesture on the view followed by a LongPressedEffect for the long press.

    Thursday, July 18, 2019 10:47 AM