Skip to content

Conversation

@KarthikRajaKalaimani
Copy link
Contributor

@KarthikRajaKalaimani KarthikRajaKalaimani commented Sep 9, 2025

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.

  • Android
  • Windows
  • iOS
  • Mac

Reference:

N/A

Issues Fixed:

Fixes #20615

Screenshots

Before After
Screen.Recording.2025-09-09.at.4.11.07.PM.mov
Screen.Recording.2025-09-09.at.4.10.03.PM.mov

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Sep 9, 2025
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz jsuarezruiz added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label Sep 10, 2025
Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

Pending snapshots:
image

@KarthikRajaKalaimani KarthikRajaKalaimani marked this pull request as ready for review September 11, 2025 05:13
@KarthikRajaKalaimani KarthikRajaKalaimani requested a review from a team as a code owner September 11, 2025 05:13
@KarthikRajaKalaimani
Copy link
Contributor Author

Pending snapshots: image

I have added pending snapshots.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).


internal static bool HasSelectedVisualState(this VisualElement element)
{
var groups = VisualStateManager.GetVisualStateGroups(element);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

Copilot AI review requested due to automatic review settings October 27, 2025 13:03
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@sheiksyedm
Copy link
Contributor

/rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CollectionView selecteditem background lost if collectionview (or parent) IsEnabled changed.

3 participants