Grid's GestureRecognizers not working

Jassim Al Rahma 1,521 Reputation points
2021-09-12T16:17:10.553+00:00

Hi,

I am trying to use GestureRecognizers with my Grid as you can see in below code but the TapGestureRecognizerShowChannels_Tapped is not getting fired.

<Grid Grid.Row="0" Margin="0,20,0,0">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <SyncfusionAvatar:SfAvatarView x:Name="ChannelAvatarLogo" Grid.Column="0" Grid.RowSpan="2" Margin="0,0,10,10" 
        ContentType="Initials" 
        AvatarName="{Binding channel_name}"
        BackgroundColor="Black" 
        BorderColor="Black" 
        InitialsColor="White"
        InitialsType="DoubleCharacter" 
        AvatarShape="Custom" 
        ImageSource="{Binding channel_logo}"
        HorizontalOptions="Center"
        VerticalOptions="Start"
        WidthRequest="50" 
        HeightRequest="50"
        CornerRadius="5" />

    <Label x:Name="LabelChannelName" Grid.Column="1" Grid.Row="0" Style="{StaticResource BaseLabel}" FontAttributes="Bold" />
    <Label x:Name="LabelChannelCountry"  Grid.Column="1" Grid.Row="1" Style="{StaticResource BaseLabel}" />

    <BoxView Grid.Row="2" Grid.ColumnSpan="2" HeightRequest="1" Color="LightGray" Margin="0, 10, 0, 10" />
<Grid.GestureRecognizers>
    <TapGestureRecognizer Tapped="TapGestureRecognizerShowChannels_Tapped" NumberOfTapsRequired="1" />                 
</Grid.GestureRecognizers>
</Grid>

Kindly help..

Thanks,
Jassim

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,223 questions
{count} votes

2 answers

Sort by: Most helpful
  1. stone z 76 Reputation points
    2021-09-13T02:57:46.043+00:00
    <ContentView HorizontalOptions="FillAndExpand"
                 VerticalOptions="FillAndExpand"
                 Grid.Row="0"
                 Grid.Column="0">
        <ContentView.GestureRecognizers>
            <TapGestureRecognizer Tapped="TapGestureRecognizerShowChannels_Tapped"  />
        </ContentView.GestureRecognizers>
    </ContentView>
    

  2. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,261 Reputation points Microsoft Vendor
    2021-09-17T03:17:46.29+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    I move the TapGestureRecognizer to top place like following screenshot. it worked as normal. That is weird.

    132943-image.png

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.