xamarinxamarin.formsmaui

Collection View Clicked not working in .NET MAUI


I have added a collection view in my .NET MAUI application where I have used the following code inside my collection view.

  <Border Padding="10,0,10,0" Margin="3,3,3,3" StrokeShape="RoundRectangle 5,5,5,5" BackgroundColor="White">
    <Grid RowSpacing="5">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Frame Grid.Row="0" HeightRequest="200" WidthRequest="250" CornerRadius="0" Padding="0" IsClippedToBounds="True">
        <Image Source="{Binding FullImageUrl}" Aspect="Fill"/>
      </Frame>
      <Label Grid.Row="1" FontSize="Subtitle" Text="{Binding Name}" Padding="15,0"/>
      <Label Grid.Row="2" FontSize="Small" Text="{Binding Address}" WidthRequest="250" Padding="15,0" LineBreakMode="TailTruncation"/>
      <Label Grid.Row="3" FontSize="Subtitle" TextColor="#1d94ab" Padding="15, 0" Text="{Binding Price}"/>
    </Grid>
  </Border>

The clicked event of the collection view is not working. When I don't use Frame then it works but with Frame it doesn't work. I need Frame because I want a rounded corner cells in my collection view.


Solution

  • It's a bug in .NET MAUI android version. On IOS Frame inside the collection view works perfectly but there's a problem with the android version. I'll suggest you to use Border Control instead of Frame because with Border control you can also use the rounded corners or corner radius and the clicked event will work on both ios and android.