xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] Android ListView SelectedItem highlighting #15647

Closed ES-2000 closed 11 months ago

ES-2000 commented 1 year ago

Description

Setting ListView.SelectedItem from within a cell highlights the cell below the selected one. This only occurs under Android and not UWP. The correct Item gets set, and if a ViewModel binds on the SelectedItem, the correct Item gets set in the ViewModel. So, this seems to be a purely visual problem, and everything functions as it should in code. Setting the SelectedItem form within the ViewModel also works without issues. This first Xamarin.Forms Version with this bug is 5.0.0.2515. Older Versions work correctly.

Steps to Reproduce

  1. Create a ListView with a custom cell.
  2. Set the SelectedItem of the ListView from within the cell, i.e. by using Xamarin.CommunityToolkit.Effects.TouchEffect to implement a PressCommand
  3. Fill the ListView with some entries
  4. The entry below the one set from within the cell will be highlighted

Expected Behavior

The SelectedItem of the ListView should be highlighted

Actual Behavior

The entry below the SelctedItem gets highlighted.

Basic Information

• Version with issue: Xamarin.Forms Version: 5.0.0. 2515, 5.0.0.2545 • Last known good version: 5.0.0.2478 • Platform Target Frameworks: Android: 13

Screenshots

ListViewBugScreenshot

Reproduction Link

ListViewBugDemo.zip

stefanomasseroli commented 1 year ago

Same issue here