CollectionView on WinUI platform

dg2k 1,381 Reputation points
2022-06-20T18:32:06.313+00:00

I am converting a Xamarin app to .NET MAUI. CollectionView control is a major part of the design for displaying grouped items.

<CollectionView  
     Margin="6,6,6,48"  
     IsGrouped="True"  
     ItemsSource="{Binding Path=FolderCollection, Mode=OneWay}"  
     ItemsUpdatingScrollMode="KeepItemsInView"  
     SelectionMode="Multiple">  
  ...    
  
</CollectionView>  

Everything works fine in Xamarin, both on latest releases of Android (SDK 31) and Windows UWP.
IDE is Visual Studio 2022 ver 17.3.0 Preview 2.

After carrying out all migrations for .NET MAUI, everything works as expected, except a toggling tap on CollectionView group item (so as to toggle items' visibility within a group) will crash the app on Windows with Unhandled Exception.

Exception: Microsoft.UI.Xaml.UnhandledException
Exception.ToString(): "Value does not fall within the expected range."
Exception.Message: "The parameter is incorrect."

The crash is traced to populating items list that is bound to CollectionView.ItemTemplate. XAML code for Xamarin and MAUI is identical.

On Android platform, on the other hand, everything works as expected, although Android has an unrelated issue which showed up with the latest MAUI 6.4.0 as reported here.

My question: is there a known issue with Microsoft.Maui.Controls.CollectionView on WinUI platform? If so, is there a workaround to this problem?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,826 questions
{count} votes