Skip to content

[Android, iOS, Mac] Fix inconsistent Background vs BackgroundColor behavior in CollectionView selection with VSM#32669

Merged
jfversluis merged 8 commits intodotnet:inflight/currentfrom
Vignesh-SF3580:fix-32348
Dec 1, 2025
Merged

[Android, iOS, Mac] Fix inconsistent Background vs BackgroundColor behavior in CollectionView selection with VSM#32669
jfversluis merged 8 commits intodotnet:inflight/currentfrom
Vignesh-SF3580:fix-32348

Conversation

@Vignesh-SF3580
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Detail

When using a CollectionView with VisualStateManager, Background and BackgroundColor behave differently during selection.

  • Background causes the selection color to extend beyond the clipped/bordered area.
  • BackgroundColor stays within bounds and works as expected.

Root Cause

IsUsingVSMForSelectionColor() checks only for BackgroundColorProperty and does not check for BackgroundProperty. When VSM uses Background, the method returns false, so iOS/Android apply their default selection color.

Description of Change

Updated IsUsingVSMForSelectionColor() to check for both background properties so that the default selection overlay is disabled when VSM applies a selection background.

Tested the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #32348

Screenshots

iOS:

Before Issue Fix After Issue Fix
32348BeforeiOS.mov
32348AfteriOS.mov

Android:

Before Issue Fix After Issue Fix
32348AndroidBefore.mov
32348AndroidAfter.mov

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 17, 2025
@sheiksyedm sheiksyedm marked this pull request as ready for review November 17, 2025 14:56
Copilot AI review requested due to automatic review settings November 17, 2025 14:56
Copy link
Contributor

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 an inconsistency in CollectionView where Background and BackgroundColor properties behave differently during item selection when using VisualStateManager (VSM). The root cause was that IsUsingVSMForSelectionColor() only checked for BackgroundColorProperty but not BackgroundProperty, causing the default platform selection color to be applied when VSM used the Background property.

Key changes:

  • Updated IsUsingVSMForSelectionColor() to check both BackgroundProperty and BackgroundColorProperty
  • Added comprehensive UI test demonstrating the fix
  • Included screenshot verification for iOS and Android

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Controls/src/Core/Handlers/Items/iOS/TemplatedCell.cs Added BackgroundProperty check in iOS implementation
src/Controls/src/Core/Handlers/Items2/iOS/TemplatedCell2.cs Added BackgroundProperty check in iOS Items2 implementation
src/Controls/src/Core/Handlers/Items/Android/TemplatedItemViewHolder.cs Added BackgroundProperty check in Android implementation
src/Controls/tests/TestCases.HostApp/Issues/Issue32348.cs Test page demonstrating Background vs BackgroundColor with VSM
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32348.cs NUnit test with screenshot verification
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/*.png iOS screenshot baseline
src/Controls/tests/TestCases.Android.Tests/snapshots/android/*.png Android screenshot baseline

Comment on lines +279 to +280
if (setter.Property.PropertyName == VisualElement.BackgroundColorProperty.PropertyName ||
setter.Property.PropertyName == VisualElement.BackgroundProperty.PropertyName)
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider extracting the property name checks into a local variable or using a helper method to reduce duplication. This pattern is repeated across three files (iOS TemplatedCell.cs, iOS TemplatedCell2.cs, and Android TemplatedItemViewHolder.cs), making it harder to maintain if additional background-related properties need to be checked in the future.

Copilot uses AI. Check for mistakes.
@sheiksyedm
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sheiksyedm
Copy link
Contributor

/rebase

StephaneDelcroix
StephaneDelcroix approved these changes Nov 24, 2025
@sheiksyedm
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis jfversluis changed the base branch from main to inflight/current December 1, 2025 10:42
@jfversluis jfversluis added this to the .NET 10.0 SR3 milestone Dec 1, 2025
@jfversluis jfversluis merged commit 08ced66 into dotnet:inflight/current Dec 1, 2025
155 of 163 checks passed
@Vignesh-SF3580 Vignesh-SF3580 added the community ✨ Community Contribution label Dec 3, 2025
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…onView selection (#32669)

added testcase.

Update Issue32348.cs

Update Issue32348.cs

added android snap.

added ios snap

Added windows and mac snapshots.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…onView selection (#32669)

added testcase.

Update Issue32348.cs

Update Issue32348.cs

added android snap.

added ios snap

Added windows and mac snapshots.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…onView selection (#32669)

added testcase.

Update Issue32348.cs

Update Issue32348.cs

added android snap.

added ios snap

Added windows and mac snapshots.
PureWeen pushed a commit that referenced this pull request Dec 3, 2025
…onView selection (#32669)

added testcase.

Update Issue32348.cs

Update Issue32348.cs

added android snap.

added ios snap

Added windows and mac snapshots.
github-actions bot pushed a commit that referenced this pull request Dec 5, 2025
…onView selection (#32669)

added testcase.

Update Issue32348.cs

Update Issue32348.cs

added android snap.

added ios snap

Added windows and mac snapshots.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-cv1 collectionview-cv2 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android platform/ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background and BackgroundColor behave differently in CollectionView selection

6 participants