Forum Xamarin.Forms

How to detect user tap event on Slider

chetszotchetszot PLMember ✭✭

Hello

I have to detect when user taps on slider. Unfortunately, TapGestureRecognizer seems not be working when attached to Slider control:

var trg = new TapGestureRecognizer();
trg.Tapped += Trg_Tapped;
SliderControl.GestureRecognizers.Add(trg);

No event is fired regardless of how many taps have been made.

I have also tried a second approach - I have derived from Slider class and tried to handle TapGestureRecognizer inside my own class. No success.

I finally tried the last thing. I have implemented a bare StackLayout and registered TapGestureRecognizer. All of the tap events were recognized correctly. However, as soon as I added Slider control as StackLayout's child - TapGestureRecognizer stopped working.

Is it possible to correctly detect tap events on Slider control without using any third-party libraries? I find this feature to be crucial for Slider in my app, but it does not work :(. I have tested all three approaches on Android (on Lollipop API 22 and above) real device and emulator. I am not able to verify this on other platforms.

Many thanks for any clues and help in advance

Best regards

Best Answer

  • chetszotchetszot PL ✭✭
    Accepted Answer

    I decided to go with CustomRenderers. I have wrapped it up with Android's native Spinner control and it works like a charm :).

Answers

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    You could try an effect - wire it up with to a command, and in the platform specific code add a handler for the relative native event

  • chetszotchetszot PLMember ✭✭
    Accepted Answer

    I decided to go with CustomRenderers. I have wrapped it up with Android's native Spinner control and it works like a charm :).

Sign In or Register to comment.