Skip to content

Conversation

tom-englert
Copy link

@tom-englert tom-englert commented Aug 22, 2025

Fixes #5428

Main PR

Description

During scroll of items-controls there are occasional null reference exceptions that crash the application. There is no chance to handle these exceptions, because there is no user code in the stack trace.

This PR adds the missing null check to avoid the null reference exceptions.

Customer Impact

Actually there are occasional crashes of the application that are not fixable by user code, see e.g. dotnet/ResXResourceManager#430

This problem occurs in any version of DotNet or NetFramework.

This PR fixes the application crashes.

Testing

No testing, impossible to build and run locally.

Risk

Low, it's just adding a null-check before code that crashes on null items.

Microsoft Reviewers: Open in CodeFlow

@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 07:31
@tom-englert tom-englert requested a review from a team as a code owner August 22, 2025 07:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a null reference exception crash that occurs when scrolling DataGrid controls with template columns. The issue manifests as occasional application crashes that cannot be handled by user code during items-control scrolling operations.

  • Adds a null check for dataItem before attempting to access it in the automation peer collection logic
  • Skips processing of null items instead of crashing when they are encountered
  • Provides a defensive programming approach to prevent unhandleable exceptions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataGrid with template columns causes crash when scrolling
1 participant