Skip to content
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

[Windows] Fixed VisualState Update for CollectionView SelectedItem #25145

Merged
merged 4 commits into from
Oct 15, 2024

Conversation

Vignesh-SF3580
Copy link
Contributor

@Vignesh-SF3580 Vignesh-SF3580 commented Oct 9, 2024

RootCause

When the SelectedItem is programmatically changed in the collection, the VisualState of the corresponding item does not update as expected. This occurs because the SelectionChanged function restricts visual state changes based on a boolean flag, which prevents the necessary state transitions when the selection is updated programmatically.

Description of Change

This fix ensures that the visual state of items in CollectionView is properly updated when the selection changes. A new method, UpdateItemContentControlSelection, is introduced to handle the selection state of item controls, ensuring consistent updates regardless of whether the selection is made programmatically or by the user. This resolves the issue where item visual states were not being correctly updated after selection changes.

Issues Fixed

Fixes #22104

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshots

Before After
CollectionView_VS_Issue.mp4
CollectionView_VS_Fixed.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Oct 9, 2024
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.

@jsuarezruiz jsuarezruiz added platform/windows 🪟 area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Oct 9, 2024
@Vignesh-SF3580 Vignesh-SF3580 changed the title [Windows [Windows] Fixed VisualState Update for CollectionView SelectedItem Oct 9, 2024
@Vignesh-SF3580 Vignesh-SF3580 marked this pull request as ready for review October 10, 2024 06:56
@Vignesh-SF3580 Vignesh-SF3580 requested a review from a team as a code owner October 10, 2024 06:56
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(129,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(164,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(246,36): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ListViewBase' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,24): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,94): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(841,9): error MSB3073: The command ""C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\..\tools\net6.0\..\net472\XamlCompiler.exe" "D:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net8.0-windows10.0.19041.0\\input.json" "D:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net8.0-windows10.0.19041.0\\output.json"" exited with code 1. [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(129,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(164,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(246,36): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ListViewBase' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,24): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,94): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]

@Vignesh-SF3580
Copy link
Contributor Author

D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(129,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(164,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(246,36): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ListViewBase' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,24): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,94): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\Microsoft.UI.Xaml.Markup.Compiler.interop.targets(841,9): error MSB3073: The command ""C:\Users\cloudtest\.nuget\packages\microsoft.windowsappsdk\1.5.240802000\buildTransitive\..\tools\net6.0\..\net472\XamlCompiler.exe" "D:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net8.0-windows10.0.19041.0\\input.json" "D:\a\_work\1\s\artifacts\obj\Controls.Core\Release\net8.0-windows10.0.19041.0\\output.json"" exited with code 1. [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.19041.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(129,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(164,4): error CS0103: The name 'UpdateItemContentControlSelection' does not exist in the current context [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(246,36): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ListViewBase' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,24): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]
D:\a\_work\1\s\src\Controls\src\Core\Handlers\Items\SelectableItemsViewHandler.Windows.cs(250,94): error CS0120: An object reference is required for the non-static field, method, or property 'ItemsViewHandler<TItemsView>.ItemsView' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-windows10.0.20348.0]

We have validated the issue and resolved it. Could you please check?

@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Oct 11, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen merged commit d53bdea into dotnet:main Oct 15, 2024
97 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
@samhouts samhouts added fixed-in-9.0.10 fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView community ✨ Community Contribution fixed-in-9.0.10 fixed-in-net8.0-nightly This may be available in a nightly release! partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows 🪟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VisualState Setters not working properly on Windows for a CollectionView
6 participants