-
Notifications
You must be signed in to change notification settings - Fork 1.9k
CollectionView selecteditem background lost if collectionview (or parent) IsEnabled changed. #31540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jsuarezruiz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
|
||
| internal static bool HasSelectedVisualState(this VisualElement element) | ||
| { | ||
| var groups = VisualStateManager.GetVisualStateGroups(element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check element, and return false if is null initially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check
element, and return false if is null initially.
I have added the null check condition for element.
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
3483294 to
96951ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
96951ca to
dfa47e9
Compare
|
/rebase |
dfa47e9 to
93177cd
Compare


Issue Details:
The user has defined an implicit style for the BackgroundColor property of a Grid, with the selected state value set to green. However, when the IsEnabled property of the CollectionView's parent Grid is changed from false to true immediately on the button click, the background color of the currently selected item (which is also a Grid) is lost.
Root Cause:
This happens because changing the IsEnabled property triggers the ChangeVisualState() method in the base VisualElement class. As a result, the visual state transitions to "Normal", overriding the previously applied "Selected" state and its associated background color.
Description of Change:
To address the issue, a selection check has been added to ensure that the "Normal" state is not forced when the element is currently in the "Selected" state. This change preserves the visual appearance of selected items by preventing the "Selected" state from being overridden during IsEnabled property changes.
Tested the behavior in the following platforms.
Reference:
N/A
Issues Fixed:
Fixes #20615
Screenshots
Screen.Recording.2025-09-09.at.4.11.07.PM.mov
Screen.Recording.2025-09-09.at.4.10.03.PM.mov