Skip to content

Add an option to discard null ItemClickEventArgs.ClickedItem before executing ListViewExtensions.Command #4453

@vgromfeld

Description

@vgromfeld

Describe the bug

The system ListView and GridView controls exhibit an unexpected behavior when their items are reordered while a ListViewBase.ItemClick event is being processed. It seems that there is some internal race inside the control since we can receive a null ItemClickEventArgs.ClickedItem in the event even if there is no null item within the list.

This issue can easily by hit in our application but I didn't find a way to reproduce this issue in a sample app 😥. It seems to depend on the complexity on the template, the load on the UI thread and the click speed.

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

In our application, clicking several times very fast on the item while the ListView/ GridView items are being reordered almost always trigger the issue.

Expected behavior

There is two ways to work around this issue:

  1. Add a null check in all our ICommands
  2. Prevent the unexpected null event from being triggered.

Option 1 is not viable on my side, so I'd like to add an option to ListViewExtensions to add the ability to discard the null value at the ListViewExtensions.Command level.

Screenshots

No response

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)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Nuget packages

No response

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions