[iOS][CV2]Fixed Selected item color changes from lightskyblue to lightgray after scrolling when deploying ManualMaui Demo project on iOS 26.1#32822
Merged
jfversluis merged 3 commits intodotnet:inflight/currentfrom Nov 27, 2025
Conversation
…r scrolling when deploying ManualMaui Demo project on iOS 26.1
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an iOS-specific issue where CollectionView selected item background colors defined via VisualStateManager incorrectly revert to the default gray color when cells are reused during scrolling. The fix ensures that when a cell is reused for a selected item, the correct visual state and selection color are reapplied.
Key Changes:
- Added logic to reapply VisualStateManager states and selection colors when binding a cell that is in the selected state
- The fix is specific to iOS CollectionView2 implementation (Items2 handlers)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jfversluis
approved these changes
Nov 27, 2025
PureWeen
pushed a commit
that referenced
this pull request
Dec 3, 2025
…r scrolling when deploying ManualMaui Demo project on iOS 26.1 (#32822) Fix optimized Update src/Controls/src/Core/Handlers/Items2/iOS/TemplatedCell2.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
github-actions bot
pushed a commit
that referenced
this pull request
Dec 5, 2025
…r scrolling when deploying ManualMaui Demo project on iOS 26.1 (#32822) Fix optimized Update src/Controls/src/Core/Handlers/Items2/iOS/TemplatedCell2.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Details:
The user has implemented a VisualStateManager for the Grid.BackgroundColor (which is Item template in collectionview) property to apply a selected background color. However, on the iOS platform, the selected item’s background color changes unexpectedly—from LightSkyBlue back to the default gray—when scrolling from bottom to top.
Root Cause:
iOS uses a native UICollectionView, which reuses cells by default. When the collection view loads scrollable items, it initially creates only the cells required for the visible area. As the user scrolls, previously created cells are reused or recreated for new items.
When scrolling back to a previously selected item, the corresponding cell is reused and recreated. At this point, the selected cell incorrectly receives the default gray background color, because in the GetCell method of the ItemsViewController2 class (line 112). the reused cell is instantiated with the default background color defined in the constructor of ItemsViewCell2. The selected background color is not re-applied to the reused cell, causing the color to appear as gray.
Description of Change:
To ensure the correct selected state is applied when a cell is reused:
These updates were added to the BindVirtualView method in the TemplatedCell2 class to ensure the correct selected background color is consistently applied, even when cells are reused.
Tested the behavior in the following platforms.
The test case for this scenario is not included in this PR, because the issue occurs very randomly. So, manually tested the fix.
Reference:
N/A
Issues Fixed:
Fixes #32493
Closes #32795
Screenshots
BeforeFix.mov
AfterFix.mov