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

[Windows] Fixed NRE when clearing ListView after navigating back #27274

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SubhikshaSf4851
Copy link

@SubhikshaSf4851 SubhikshaSf4851 commented Jan 22, 2025

RootCause:

  • The issue arises because the CollectionChanged event of the virtual view was not unwired in the DisconnectHandler method in ListViewRender. As a result, the CollectionChanged event was wired multiple times for each navigation, and it was never unwired. When we use the saved instance, the CollectionChanged event is wired for the second time, while the first one was never unwired. When we clear the item source, the CollectionChanged event is triggered for the first element. Since it was disconnected, we receive the virtual view as null.

Description Of Change:

  • I have unwired the CollectionChanged event in the DisconnectHandler method.

Tested the behaviour in the following platforms.

  • Windows

Issue Fixed:
Fixes #26498

Before Fix:

Issue26498BeforeFix.mp4

After Fix:

Issue26498AfterFix.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jan 22, 2025
@SubhikshaSf4851 SubhikshaSf4851 changed the title Fix for Issue 26498 - Null Exception in listview Issue on Windows - Exception thrown: 'System.NullReferenceException' in Microsoft.Maui.Controls.dll Jan 22, 2025
@vishnumenon2684 vishnumenon2684 added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jan 22, 2025
@SubhikshaSf4851
Copy link
Author

@dotnet-policy-service agree company="Syncfusion, Inc."

@jsuarezruiz jsuarezruiz added platform/windows 🪟 area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Jan 22, 2025
@dotnet dotnet deleted a comment from azure-pipelines bot Jan 22, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@SubhikshaSf4851 SubhikshaSf4851 changed the title Issue on Windows - Exception thrown: 'System.NullReferenceException' in Microsoft.Maui.Controls.dll [Windows] Fixed NRE when clearing ListView after navigating back Jan 23, 2025
@SubhikshaSf4851 SubhikshaSf4851 marked this pull request as ready for review January 23, 2025 11:36
@SubhikshaSf4851 SubhikshaSf4851 requested a review from a team as a code owner January 23, 2025 11:36
@jsuarezruiz
Copy link
Contributor

/azp run

This comment was marked as outdated.

@Mark-NC001
Copy link

@SubhikshaSf4851 I have tried your fix on my repro (I logged 26577, which has been closed as duplicate of 26498) - and the fix does stop the error, thank you.

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Feb 4, 2025

/azp run

This comment was marked as off-topic.

@jfversluis
Copy link
Member

/rebase

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows 🪟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue on Windows - Exception thrown: 'System.NullReferenceException' in Microsoft.Maui.Controls.dll
6 participants