Skip to content

ListViewExtensions.SmoothScrollIntoViewWithIndexAsync can throw a NullReferenceException if target SelectorItem is null #4829

Open
@Sergio0694

Description

@Sergio0694

Describe the bug

We recently hit a bug in the Microsoft Store where ListViewExtensions.SmoothScrollIntoViewWithIndexAsync can throw a NullReferenceException if target SelectorItem is null. The issue is this line:

var transform = selectorItem.TransformToVisual((UIElement)scrollViewer.Content);

The issue is the returned selector can still be null, as ContainerFromIndex isn't guaranteed to return a not null value. This might happen in some weird corner cases eg. when a page is being unloaded or similar. The extension should likely just check that and do nothing if that's the case.

Regression

No

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Visual Studio Version

2022

Metadata

Metadata

Assignees

Labels

bug 🐛An unexpected issue that highlights incorrect behaviorextensions ⚡partner ⏹Label for issues that are being depended on or blocking Toolkit partners.

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions