Skip to content

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 Details

On Windows, the CollectionView selection state was not visible.

Root Cause

When adding new container styles, the default styles was not added.

Description of Change

Used the BasedOn property to include the default style along with the new style, so selection states remain visible.

Tested the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #30868

Screenshots

SelectionMode: Multiple

Before Issue Fix After Issue Fix
image image

SelectionMode: Single

Before Issue Fix After Issue Fix
image image

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 12, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@Vignesh-SF3580! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Aug 12, 2025
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added platform/windows area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Aug 12, 2025
var margin = WinUIHelpers.CreateThickness(0, v, 0, v);

var style = new WStyle(typeof(ListViewItem));
var defaultStyle = GetDefaultStyle("DefaultListViewItemStyle");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we store the resourceKey in a field and use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the code to store the resourceKey in a field.

@Vignesh-SF3580 Vignesh-SF3580 marked this pull request as ready for review August 13, 2025 12:45
Copilot AI review requested due to automatic review settings August 13, 2025 12:45
@Vignesh-SF3580 Vignesh-SF3580 requested a review from a team as a code owner August 13, 2025 12:45
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 issue where CollectionView selected item states were not visible on Windows. The root cause was that when creating custom container styles for spacing and layout, the default styles containing selection visual states were being overridden completely instead of being extended.

Key changes:

  • Modified style creation to use BasedOn property to inherit from default styles
  • Added UI test to verify selection visibility behavior
  • Applied fix to both GridView and ListView item container styles

Reviewed Changes

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

File Description
src/Controls/src/Core/Handlers/Items/StructuredItemsViewHandler.Windows.cs Updated style creation logic to inherit from default styles using BasedOn property, ensuring selection states remain visible
src/Controls/tests/TestCases.HostApp/Issues/Issue30868.cs Added test page with CollectionView configured for multiple selection mode to demonstrate the fix
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30868.cs Added UI test that taps an item and verifies selection state through screenshot comparison

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

VerticalTextAlignment = TextAlignment.Center,
Padding = new Thickness(10, 0, 10, 10)
};
label.SetBinding(Label.TextProperty, ".");
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The Label element lacks an AutomationId property. According to the testing guidelines, all interactive UI elements should have unique AutomationIds to ensure proper test automation. Consider adding label.AutomationId = (string)label.BindingContext; or a similar unique identifier.

Copilot uses AI. Check for mistakes.
[Category(UITestCategories.CollectionView)]
public void CollectionViewSelectionMode()
{
App.WaitForElement("Item 2");
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The test is waiting for an element with text 'Item 2', but the corresponding HostApp page doesn't assign AutomationIds to the Label elements within the CollectionView items. This could cause the test to fail because WaitForElement may not be able to locate the element reliably without proper AutomationIds.

Copilot uses AI. Check for mistakes.
var margin = WinUIHelpers.CreateThickness(h, v, h, v);

var style = new WStyle(typeof(GridViewItem));
var defaultStyle = GetDefaultStyle(GridViewItemStyleKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

The GetDefaultStyle() method could return null if the resource key doesn't exist. Must not happen except mistake, but, can protect it?

if (defaultStyle is not null)
{
    style.BasedOn = defaultStyle;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz Added a null check to avoid unexpected failures.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

With the changes, requires updates in the reference snapshot from several Windows tests related with CV selection:
image
Could you review it?

{
App.WaitForElement("Item 2");
App.Tap("Item 2");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Pending snapshot on Windows and macOS.
image
Could you commit the images?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve committed the images for Windows and macOS.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we modify it a little bit? Use

public static void SetLightTheme(this IApp app)
SetLightTheme and SetDarkTheme, and validating a screenshot in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz I have updated the test cases based on your suggestion. Let me know if any further changes are needed.

@Vignesh-SF3580
Copy link
Contributor Author

With the changes, requires updates in the reference snapshot from several Windows tests related with CV selection: image Could you review it?

@jsuarezruiz Previously, the default style for SelectedItems was not updating properly. It is now updated along with the default styles. I have updated these with the newly generated images.

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen added this to the .NET 9 SR11 milestone Sep 4, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Sep 4, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Changes Requested in MAUI SDK Ongoing Sep 9, 2025
@PureWeen PureWeen modified the milestones: .NET 9 SR11, .NET 9 SR12 Sep 10, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Sep 10, 2025
PropertyChangedEventHandler _layoutPropertyChanged;
const string ListViewItemStyleKey = "DefaultListViewItemStyle";
const string GridViewItemStyleKey = "DefaultGridViewItemStyle";
static WStyle _listViewItemStyle;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could validate if user switches between Light/Dark themes works as expected or static cached styles won't update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz I have validated switching between Light and Dark themes, and it works as expected. The checkbox colors are updated correctly based on the theme changes defined in the default style. I have attached a video for reference.

31126Theme.mp4

{
App.WaitForElement("Item 2");
App.Tap("Item 2");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we modify it a little bit? Use

public static void SetLightTheme(this IApp app)
SetLightTheme and SetDarkTheme, and validating a screenshot in both cases.

@PureWeen
Copy link
Member

PureWeen commented Oct 6, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

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.

Re-running the Windows CollectionView UITests. The process was canceled after some time running.

@Vignesh-SF3580
Copy link
Contributor Author

Re-running the Windows CollectionView UITests. The process was canceled after some time running.

@jsuarezruiz Changing themes continuously fails on CI for Windows. It seems that theme changes do not work on Windows, and this was already noted in the implemented PR.
PR: #25863

@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR12, .NET 10.0 GA Oct 8, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@sheiksyedm sheiksyedm moved this from Changes Requested to Ready To Review in MAUI SDK Ongoing Oct 13, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Oct 14, 2025
@PureWeen PureWeen merged commit e9d69ec into dotnet:main Oct 15, 2025
129 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Oct 15, 2025
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 p/0 Work that we can't release without partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Right icon present to show selected tag that icon color contrast with back ground color less than 3:1 :A11y_.NET maui_Projact_Non text Contrast

5 participants