Xamarin.Forms CollectionView inside Frame can't be tapped

Damian Slanovic 6 Reputation points
2021-11-02T15:21:24.38+00:00

I have a CollectionView with GestureRecognizers working fine. Since I want this collectionview to have rounded corners, I put it inside a Frame. Once inside the frame, GestureRecognizers stop working. This is a normal behaviour?

Thanks in advance
Damian.

        <!--<Frame BackgroundColor="Black" HasShadow="false"
               CornerRadius="20" Opacity="1" HorizontalOptions="CenterAndExpand"
               HeightRequest="100" Padding="0" Margin="10">-->
        <CollectionView ItemsSource="{Binding MenuCVItems}" BackgroundColor="Transparent"
                    ItemsLayout="HorizontalList" x:Name="xamlCVMenu">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Grid Padding="10">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="50" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="70" />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Row="0" Grid.Column="0"
                           Source="{Binding ImageUrl}"
                           Aspect="AspectFill"
                           HeightRequest="60" 
                           WidthRequest="60">
                            <Image.GestureRecognizers>
                                <TapGestureRecognizer NumberOfTapsRequired="1"
                                    Command="{Binding Path=BindingContext.NavegarCommand, Source={x:Reference Name=xamlCVMenu}}" 
                                    CommandParameter="{Binding .}">
                                </TapGestureRecognizer>
                            </Image.GestureRecognizers>
                        </Image>
                        <Label Grid.Row="1" Grid.Column="0" 
                           Text="{Binding Name}" TextColor="Black"
                           FontAttributes="Bold"
                           HorizontalOptions="CenterAndExpand"
                           LineBreakMode="TailTruncation">
                            <Label.GestureRecognizers>
                                <TapGestureRecognizer NumberOfTapsRequired="1"
                                    Command="{Binding Path=BindingContext.NavegarCommand, Source={x:Reference Name=xamlCVMenu}}" 
                                    CommandParameter="{Binding .}">
                                </TapGestureRecognizer>
                            </Label.GestureRecognizers>
                        </Label>
                    </Grid>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
        <!--</Frame>-->
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,380 questions
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.