collectionviewmauiselectionchanged

CollectionView SelectionChanged method not triggering when tapping the item directly .NET MAUI


I'm creating a CollectionView in .net MAUI where i'm using Frame control inside the data template. As a result of that, when I tap directly on the item, the SelectionChanged method is not being triggered and will trigger only if I click on the frame border or outside of it. Below sample code and picture. Is this a bug in MAUI or I'm doing something wrong? I had the same setup in Xamarin and it was working with no issues.

XAML

 <CollectionView x:Name="scheduleItemsCollection" 
                                    SelectionChanged="scheduleItemsCollection_SelectionChanged"
                                    SelectionMode="Single"
                                  >
                        <CollectionView.ItemsLayout>
                            <GridItemsLayout Orientation="Vertical"
                                     Span="2"
                                     />
                        </CollectionView.ItemsLayout>

                        <CollectionView.ItemTemplate>
                            <DataTemplate>

                                <Grid Padding="5" RowSpacing="0">

                                 <Frame CornerRadius="40" BorderColor="Gray"> 
                                        <StackLayout Spacing="0" BackgroundColor="White">
                                            <Label  Text="{Binding bookingDayArabic}" />
                                            <Label   Text="{Binding bookingDateD}" />
                                            <StackLayout Orientation="Horizontal">
                                              
                                                <Label Text="{Binding slotsAvailable}" HorizontalOptions="CenterAndExpand" />
                                                <Label Text="عدد الطلبات:"/>
                                            </StackLayout>
                                        </StackLayout>
                             </Frame> 
                                </Grid>


                            </DataTemplate>

                        </CollectionView.ItemTemplate>

                    </CollectionView>

enter image description here


Solution

  • Yes, it is the case as you said. Thanks for your support and feedback for maui.

    I have created a new issue about this problem.

    You can follow it up here: https://github.com/dotnet/maui/issues/9567.

    Have a nice day.