I'm unable to use GestureRecognizers on a button. Putting GestureRecognizers on StackLayout, ContentView etc is working fine.
GestureRecognizers like Tapped and Swiped should work as expected.
None of those GestureRecognizers gets called
N/A
https://github.com/ysmoradi/XFButtonGestureRecognizersIssue/blob/master/src/App/App.xaml
<?xml version="1.0" encoding="utf-8" ?>
<Application
x:Class="XFButtonGestureRecognizersIssue.App"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Application.MainPage>
<ContentPage x:Name="Page">
<StackLayout CompressedLayout.IsHeadless="True">
<Button Text="Test 1">
<View.GestureRecognizers>
<ClickGestureRecognizer Clicked="TapGestureRecognizer_Tapped" />
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</View.GestureRecognizers>
</Button>
<Label Text="Test 2">
<View.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</View.GestureRecognizers>
</Label>
</StackLayout>
</ContentPage>
</Application.MainPage>
</Application>
public partial class App : Application
{
public App()
{
InitializeComponent();
}
void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
((VisualElement)sender).BackgroundColor = Color.LightBlue;
}
}
Hi, this never worked in XF, so is not really a bug, more a enhancement. Normally user's use the click event.
Marking this to be look further as an enhancement.
Can you please provide a scenario you need this also to help us out.
Thanks.
It's working with images, content views etc.
It has a problem with button only. I'm willing to have double tap.
TapGestureRecognizer has a property for this. (NumberOfRequiredTap). It's also useful for right click on UWP.
I'm facing the same issue with ImageButton too (XF 3.4)
I'm facing this same issue in Image control. It's working fine in phones but not working in iPad.
<ContentView AbsoluteLayout.LayoutBounds="0.99,5,25,25" AbsoluteLayout.LayoutFlags="XProportional">
<Image Source="uploadcamera" Aspect="AspectFit" />
<ContentView.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ChangePhotoCommand}" NumberOfTapsRequired="1"/>
</ContentView.GestureRecognizers>
</ContentView>
Work around:
I have fix this issue by replacing Absolute Layout with Grid Layout
Most helpful comment
I'm facing the same issue with ImageButton too (XF 3.4)