Adding following code crashes app with following exception: The value "MauiApp10.Group" is not of type "System.Int32" and cannot be used in this generic collection. (Parameter 'value')
<CollectionView.GroupFooterTemplate>
<DataTemplate x:DataType="local:Group">
<Border Background="Green"
HeightRequest="20">
<Label Text="{Binding Total}" />
</Border>
</DataTemplate>
</CollectionView.GroupFooterTemplate>
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
at Microsoft.Maui.Controls.Platform.ObservableItemTemplateCollection.AddToSource(NotifyCollectionChangedEventArgs args)
at Microsoft.Maui.Controls.Platform.ObservableItemTemplateCollection.TemplateCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value)
at Microsoft.Maui.Controls.Platform.GroupTemplateContext..ctor(ItemTemplateContext headerItemTemplateContext, ItemTemplateContext footerItemTemplateContext, Object items)
at Microsoft.Maui.Controls.Platform.GroupedItemTemplateCollection.CreateGroupTemplateContext(Object group)
at Microsoft.Maui.Controls.Platform.GroupedItemTemplateCollection..ctor(IEnumerable itemsSource, DataTemplate itemTemplate, DataTemplate groupHeaderTemplate, DataTemplate groupFooterTemplate, BindableObject container, IMauiContext mauiContext)
at Microsoft.Maui.Controls.Platform.TemplatedItemSourceFactory.CreateGrouped(IEnumerable itemsSource, DataTemplate itemTemplate, DataTemplate groupHeaderTemplate, DataTemplate groupFooterTemplate, BindableObject container, IMauiContext mauiContext)
at Microsoft.Maui.Controls.Handlers.Items.GroupableItemsViewHandler`1.CreateCollectionViewSource()
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewHandler`1.UpdateItemsSource()
at Microsoft.Maui.Controls.Handlers.Items.SelectableItemsViewHandler`1.UpdateItemsSource()
at Microsoft.Maui.Controls.Handlers.Items.ItemsViewHandler`1.MapItemsSource(ItemsViewHandler`1 handler, ItemsView itemsView)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Handlers.ViewHandler`2.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler`2.SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler)
at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Handlers.ViewHandler`2.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view)
at Microsoft.Maui.Handlers.ViewHandler`2.SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
at Microsoft.Maui.Handlers.WindowHandler.MapContent(IWindowHandler handler, IWindow window)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0.<Add>b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
at Microsoft.Maui.Platform.ElementExtensions.SetHandler(IWinRTObject nativeElement, IElement element, IMauiContext context)
at Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler(Window platformWindow, IWindow window, IMauiContext context)
at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Application platformApplication, IApplication application, OpenWindowRequest args)
at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Application platformApplication, IApplication application, LaunchActivatedEventArgs args)
at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
at Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(LaunchActivatedEventArgs args)
at ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(IntPtr thisPtr, IntPtr args)
Android has no such issue. iOS wasn't tested.
Description
Adding following code crashes app with following exception: The value "MauiApp10.Group" is not of type "System.Int32" and cannot be used in this generic collection. (Parameter 'value')
Stack trace:
Changing refrenced type from int to string only changes exception to:
The value "MauiApp10.Group" is not of type "System.String" and cannot be used in this generic collection. (Parameter 'value')
Android has no such issue. iOS wasn't tested.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/Vroomer/MAUI-CollectionView-templates-bugs.git
Version with bug
8.0.0-rc.2.9511
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
8.0.0-rc.2.9511
Affected platforms
Windows
Affected platform versions
Windows SDK 10.0.19041.0
Did you find any workaround?
No response
Relevant log output
No response