Skip to content

[Windows] Fix for ListView ScrollTo Method throws NullReferenceException#26385

Merged
jfversluis merged 8 commits intodotnet:mainfrom
Tamilarasan-Paranthaman:fix-26345
Dec 10, 2024
Merged

[Windows] Fix for ListView ScrollTo Method throws NullReferenceException#26385
jfversluis merged 8 commits intodotnet:mainfrom
Tamilarasan-Paranthaman:fix-26345

Conversation

@Tamilarasan-Paranthaman
Copy link
Copy Markdown
Member

@Tamilarasan-Paranthaman Tamilarasan-Paranthaman commented Dec 5, 2024

Root Cause of the issue

  • The exception occurred because the scroll request was processed before the control was fully loaded, causing the dispatcher to be null.

Description of Change

  • I resolved the issue by invoking the ScrollTo method within MainThread.BeginInvokeOnMainThread. This ensures that the scroll request is executed on the main thread.

Test Case

Reference

https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.WPF/Renderers/ListViewRenderer.cs#L427

Issues Fixed

Fixes #26345

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshot

Before Issue Fix After Issue Fix
WithException.mp4
FixVideoofListView.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 5, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 5, 2024
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review December 5, 2024 14:48
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman requested a review from a team as a code owner December 5, 2024 14:48
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as draft December 5, 2024 14:50
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman marked this pull request as ready for review December 5, 2024 15:26
@Redth
Copy link
Copy Markdown
Member

Redth commented Dec 5, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tamilarasan-Paranthaman
Copy link
Copy Markdown
Member Author

/rebase

@rmarinho
Copy link
Copy Markdown
Member

rmarinho commented Dec 6, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@Tamilarasan-Paranthaman
Copy link
Copy Markdown
Member Author

Can we rebase and reenable the tests from the other prs https://github.com/dotnet/maui/pull/26367/files#diff-ddeee3ee10f01134abc383c69a74dc4a65b5e8cbfa6dd682ceeb34734c6bdd6bR1

@rmarinho, I have reenabled the test cases.

@rmarinho rmarinho requested a review from Foda December 6, 2024 19:53
@jfversluis jfversluis added the area-controls-listview ListView and TableView label Dec 9, 2024
@jfversluis jfversluis dismissed rmarinho’s stale review December 10, 2024 10:14

Feedback addressed

@jfversluis jfversluis merged commit cf30c13 into dotnet:main Dec 10, 2024
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2025
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman deleted the fix-26345 branch June 16, 2025 11:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-listview ListView and TableView community ✨ Community Contribution fixed-in-net8.0-nightly This may be available in a nightly release! fixed-in-net9.0-nightly This may be available in a nightly release! partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] ListView ScrollTo Method Throws NullReferenceException

7 participants