Skip to content

Fixed CollectionView SelectedItem binding issue on initial loading#25555

Merged
rmarinho merged 32 commits intodotnet:mainfrom
SuthiYuvaraj:SyncToolKit
Nov 26, 2024
Merged

Fixed CollectionView SelectedItem binding issue on initial loading#25555
rmarinho merged 32 commits intodotnet:mainfrom
SuthiYuvaraj:SyncToolKit

Conversation

@SuthiYuvaraj
Copy link
Copy Markdown
Contributor

@SuthiYuvaraj SuthiYuvaraj commented Oct 28, 2024

Issue Details

  1. Selected Item Binding Issue: The selected item binding does not work as expected across Windows, iOS, and Mac platforms.
  2. Visual State Issue: If a selection visual state is present, it is not applied to the view.

Root Cause

  • Windows: The selected item is reset due to the ListViewBase.IsSynchronizedWithCurrentItem property setting. Additionally, the visual state is applied before the item view control is created.
  • iOS & Mac: The selected index is not applied during initial loading, specifically after updating the ItemsSource.

Fix Details

  • Windows: The existing local variable is used to prevent resetting SelectedItem while updating the native view property. Additionally, the ItemContentControl's visual state is now applied after it is created.
  • iOS & Mac: The selected index is applied within a batch update to ensure that items are generated before applying selection.

Reference:
iOS - ios - How to select some items in the UICollectionView after it first load? - Stack Overflow

Issues Fixed

Fixes #25551
Fixes #23299

Output Screenshot

Before Issue Fix After Issue Fix
Before Fix video After Fix video
Before Fix video After Fix video

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 28, 2024
@SuthiYuvaraj SuthiYuvaraj changed the title CollectionView Programmatic-Selection is not updated when binding the selectedItem Fixed CollectionView SelectedItem binding issue on initial loading Oct 28, 2024
@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Oct 29, 2024
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@SuthiYuvaraj SuthiYuvaraj marked this pull request as ready for review October 30, 2024 10:54
@SuthiYuvaraj SuthiYuvaraj requested a review from a team as a code owner October 30, 2024 10:54
@dotnet dotnet deleted a comment from azure-pipelines bot Oct 30, 2024
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 SR1 milestone Oct 30, 2024
@rmarinho rmarinho self-assigned this Oct 31, 2024
@jfversluis
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Copy Markdown
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

CollectionViewPreSelectionShouldUpdate

Failing

@SuthiYuvaraj
Copy link
Copy Markdown
Contributor Author

Hi @PureWeen , The CollectionViewPreSelectionShouldUpdate failed due to a missing snapshot on the Windows platform. We have now included the snapshot. Please review and let us know if there are any concerns.

@rmarinho
Copy link
Copy Markdown
Member

rmarinho commented Nov 7, 2024

/rebase

@PureWeen PureWeen modified the milestones: .NET 9 SR1, .NET 9 SR1.1 Nov 7, 2024
@dotnet dotnet deleted a comment from azure-pipelines bot Nov 12, 2024
@rmarinho
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho
Copy link
Copy Markdown
Member

/rebase

@PureWeen PureWeen modified the milestones: .NET 9 SR1.1, .NET 9 SR2 Nov 25, 2024
@rmarinho rmarinho requested review from Foda, PureWeen, jsuarezruiz and rmarinho and removed request for Eilon, PureWeen and StephaneDelcroix November 26, 2024 16:00
@rmarinho rmarinho merged commit 60976d1 into dotnet:main Nov 26, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
@samhouts samhouts added fixed-in-9.0.21 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 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution fixed-in-9.0.21 fixed-in-net8.0-nightly This may be available in a nightly release! partner/syncfusion Issues / PR's with Syncfusion collaboration platform/ios platform/windows

Projects

Status: Done

9 participants