Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollectionViewHandler2 null reference exception if ItemsLayout is set for Tablet but NOT Phone #26065

Closed
rysbilinski opened this issue Nov 22, 2024 · 1 comment · Fixed by #26152
Assignees
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-9.0.21 p/2 Work that is important, but is currently not scheduled for release partner/syncfusion Issues / PR's with Syncfusion collaboration platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@rysbilinski
Copy link

rysbilinski commented Nov 22, 2024

Description

Adding a collectionview to a page and only setting the ItemsLayout property for Tablet will throw a null reference exception before the page appears on mobile.

Steps to Reproduce

  1. Add A collectionview to a page, and add the following to the collection view:

<CollectionView ItemsLayout="{OnIdiom Tablet='VerticalGrid 2'}" ItemsSource="{Binding Items}" VerticalOptions="Fill">

  1. Configure builder to use the new CollectionViewHandler2:
builder.ConfigureMauiHandlers(handlers =>
                {

                    handlers.AddHandler<Microsoft.Maui.Controls.CollectionView, Microsoft.Maui.Controls.Handlers.Items2.CollectionViewHandler2>();

                    handlers.AddHandler<Microsoft.Maui.Controls.CarouselView, Microsoft.Maui.Controls.Handlers.Items2.CarouselViewHandler2>();

                });
  1. Run the application on iOS
  2. Navigate to the page and you will see a crash in Program.cs

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Link to public reproduction project repository

https://github.com/rysbilinski/CollectionViewHandler2Bugs

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.100 SR10

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

Workaround was to add the "phone" OnIdiom parameter:

<CollectionView ItemsLayout="{OnIdiom Phone='VeritcalGrid', Tablet='VerticalGrid 2'}" ItemsSource="{Binding Items}" VerticalOptions="Fill">

Relevant log output

@rysbilinski rysbilinski added the t/bug Something isn't working label Nov 22, 2024
@samhouts samhouts added platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Nov 22, 2024
@PureWeen PureWeen added this to the .NET 9 Servicing milestone Nov 22, 2024
@PureWeen PureWeen added the p/2 Work that is important, but is currently not scheduled for release label Nov 22, 2024
@ninachen03
Copy link

I can repro this issue at iOS platform on the latest 17.13.0 Preview 1.0(9.0.10 & 9.0.0-preview.7.24407.4)The CVhandler2 was introduced in .NET 9.0, so it cannot be verified with NET8. I will keep the potential-regression lab for now, because users say it works on 8.0.100, which is confusing information to me. If you have any question, please feel free to contact us.
Image

@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Nov 26, 2024
@vishnumenon2684 vishnumenon2684 self-assigned this Nov 26, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in MAUI SDK Ongoing Dec 4, 2024
@rmarinho rmarinho modified the milestones: .NET 9 Servicing, .NET 9 SR2 Dec 4, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView fixed-in-9.0.21 p/2 Work that is important, but is currently not scheduled for release partner/syncfusion Issues / PR's with Syncfusion collaboration platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
7 participants