-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fix for Assigning null to the SelectedItem of the CollectionView in the SelectionChanged event does not clear the selection #29288
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
Merged
PureWeen
merged 3 commits into
dotnet:inflight/current
from
SyedAbdulAzeemSF4852:fix-10025
Jun 6, 2025
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| namespace Controls.TestCases.HostApp.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 10025, "Assigning null to the SelectedItem of the CollectionView in the SelectionChanged event does not clear the selection as expected", PlatformAffected.UWP)] | ||
| public class Issue10025 : ContentPage | ||
| { | ||
| CollectionView collectionView; | ||
| public Issue10025() | ||
| { | ||
| Label descriptionLabel = new Label | ||
| { | ||
| AutomationId = "DescriptionLabel", | ||
| Text = "The test passes if the SelectedItem is set to null and no visual selection indicator is displayed; otherwise, it fails", | ||
| Margin = new Thickness(10), | ||
| }; | ||
|
|
||
| collectionView = new CollectionView | ||
| { | ||
| SelectionMode = SelectionMode.Single, | ||
| ItemsSource = new List<string> { "Item1", "Item2" }, | ||
| ItemTemplate = new DataTemplate(() => | ||
| { | ||
| Label label = new Label(); | ||
|
|
||
| label.SetBinding(Label.TextProperty, "."); | ||
| label.SetBinding(Label.AutomationIdProperty, "."); | ||
|
|
||
| return label; | ||
| }) | ||
| }; | ||
|
|
||
| collectionView.SelectionChanged += SelectionChangedEvent; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Padding = new Thickness(20), | ||
| Children = | ||
| { | ||
| descriptionLabel, | ||
| collectionView | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| private void SelectionChangedEvent(object sender, SelectionChangedEventArgs e) | ||
| { | ||
| collectionView.SelectedItem = null; | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue10025.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST // Select items traces are preserved Issue Link - https://github.com/dotnet/maui/issues/26187 | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue10025 : _IssuesUITest | ||
| { | ||
| public Issue10025(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Assigning null to the SelectedItem of the CollectionView in the SelectionChanged event does not clear the selection as expected"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CollectionView)] | ||
| public void VerifySelectedItemClearsOnNullAssignment() | ||
| { | ||
| App.Tap("Item1"); | ||
| App.Tap("DescriptionLabel"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.