Skip to content

Binding CollectionView/CarouselView to lists of primitive types doesn't work on Release Builds #16021

@stefanpirkl

Description

@stefanpirkl

Description

A CollectionView/CarouselView bound to an IList with primitive types doesn't render items on release builds.

Tested on Windows and Android, both don't work.

Debug:
image

Release:
image

Steps to Reproduce

  1. Create a new .NET MAUI project

  2. Add a view model with a list property of type List and some elements:
    ` internal class MainPageViewModel : BindableObject
    {
    private IList _items = new List { "first value", "second value", "third value" };

     public IList<string> Items
     {
         get { return _items; }
         set { _items = value; OnPropertyChanged(nameof(Items)); }
     }
    

    }`

  3. Bind the view model to MainPage.xaml.cs:
    ` public partial class MainPage : ContentPage
    {
    MainPageViewModel viewModel = new MainPageViewModel();

     public MainPage()
     {
         InitializeComponent();
    
         BindingContext = viewModel;
     }
    

    }`

  4. Add a CollectionView to MainPage.xaml, bound to the list in MainPageViewModel:
    <CollectionView ItemsSource="{Binding Items}"> <CollectionView.ItemTemplate> <DataTemplate> <Label Text="{Binding}" /> </DataTemplate> </CollectionView.ItemTemplate> </CollectionView>

  5. Do a release build, observe that nothing is rendered.

Link to public reproduction project repository

https://github.com/stefanpirkl/bugreport-maui-collectionview-primitive-list-on-release

Version with bug

8.0.0-preview.5.8529

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Windows 10, Android 9 and up

Did you find any workaround?

Changing the List to a custom model class with a single string property in it.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions