-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed CollectionView SelectedItem binding issue on initial loading #25555
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
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
28e017a
Commit for SelectedItem
SuthiYuvaraj 8abfec8
Update Issue25551.xaml
SuthiYuvaraj d4ffe0b
Merge branch 'dotnet:main' into SyncToolKit
SuthiYuvaraj 2d158c2
Merge branch 'dotnet:main' into SyncToolKit
SuthiYuvaraj a958b61
Merge branch 'dotnet:main' into SyncToolKit
SuthiYuvaraj c22ab95
Commit for testcases
SuthiYuvaraj d9cb970
Commit for image
SuthiYuvaraj 0107ce7
Update SelectableItemsViewController.cs
SuthiYuvaraj bac9ca4
Commit for changes
SuthiYuvaraj 486a3a9
Update SelectableItemsViewController.cs
SuthiYuvaraj 66d5b3a
Update SelectableItemsViewController2.cs
SuthiYuvaraj 358ca1e
Merge branch 'dotnet:main' into SyncToolKit
SuthiYuvaraj 02caf0d
Commit for images
SuthiYuvaraj 36049cf
Commit for SelectedItem
SuthiYuvaraj 01a7a9f
Update Issue25551.xaml
SuthiYuvaraj 6d3fdc7
Commit for testcases
SuthiYuvaraj 45f1388
Commit for image
SuthiYuvaraj db1de31
Update SelectableItemsViewController.cs
SuthiYuvaraj 3e47a4c
Commit for changes
SuthiYuvaraj 56f98b3
Update SelectableItemsViewController.cs
SuthiYuvaraj 18b20e8
Update SelectableItemsViewController2.cs
SuthiYuvaraj 0294624
Commit for images
SuthiYuvaraj f0c2588
Merge branch 'dotnet:main' into SyncToolKit
SuthiYuvaraj 8b25efe
Merge branch 'SyncToolKit' of https://github.com/SuthiYuvaraj/maui in…
SuthiYuvaraj c1ac334
Commit for multiple selection
SuthiYuvaraj e1bec77
Commit for images
SuthiYuvaraj ac74771
commit for image changes
SuthiYuvaraj 9b60d74
commit for image remoced
SuthiYuvaraj dabc113
image removed for windows
SuthiYuvaraj 515cf52
Added the windows platform output image
NanthiniMahalingam 2217a15
Merge branch 'main' of https://github.com/SuthiYuvaraj/maui into Sync…
NanthiniMahalingam ec8804f
Merge branch 'dotnet:main' into SyncToolKit
SuthiYuvaraj 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
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
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
Binary file added
BIN
+44.7 KB
...ases.Android.Tests/snapshots/android/CollectionViewPreSelectionShouldUpdate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions
100
src/Controls/tests/TestCases.HostApp/Issues/Issue25551.xaml
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,100 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue25551" | ||
| xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"> | ||
|
|
||
| <VerticalStackLayout> | ||
| <CollectionView AutomationId="SingleSelection" | ||
| Margin="15,0,0,15" | ||
| SelectionMode="Single" | ||
| HeightRequest="300" | ||
| ItemsSource="{Binding Items}" | ||
| SelectedItem="{Binding SelectedItem}" | ||
| VerticalOptions="Center"> | ||
| <CollectionView.ItemsLayout> | ||
| <LinearItemsLayout Orientation="Horizontal" ItemSpacing="10"/> | ||
| </CollectionView.ItemsLayout> | ||
| <CollectionView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Grid RowDefinitions="Auto,4" RowSpacing="5"> | ||
| <VisualStateManager.VisualStateGroups> | ||
| <VisualStateGroup x:Name="CommonStates"> | ||
| <VisualState x:Name="Normal"> | ||
| <VisualState.Setters> | ||
| <Setter Property="BackgroundColor" Value="Transparent"/> | ||
| <Setter TargetName="SelectedIndicator" Property="BoxView.IsVisible" Value="False"/> | ||
| </VisualState.Setters> | ||
| </VisualState> | ||
| <VisualState x:Name="Selected"> | ||
| <VisualState.Setters> | ||
| <Setter Property="BackgroundColor" Value="Transparent"/> | ||
| <Setter Property="Background" Value="Transparent"/> | ||
| <Setter TargetName="SelectedIndicator" Property="BoxView.IsVisible" Value="True"/> | ||
| </VisualState.Setters> | ||
| </VisualState> | ||
| </VisualStateGroup> | ||
| </VisualStateManager.VisualStateGroups> | ||
|
|
||
| <Label | ||
| Text="{Binding .}" | ||
| x:Name="ItemName" | ||
| FontAttributes="Bold" | ||
| FontSize="14" | ||
| VerticalOptions="Center" | ||
| HorizontalOptions="Center" | ||
| TextColor="Green"/> | ||
| <BoxView x:Name="SelectedIndicator" Color="blue" HeightRequest="4" HorizontalOptions="Fill" Grid.Row="1"/> | ||
| </Grid> | ||
| </DataTemplate> | ||
| </CollectionView.ItemTemplate> | ||
|
|
||
| </CollectionView> | ||
|
|
||
| <CollectionView AutomationId="MultipleSelection" | ||
| Margin="15,0,0,15" | ||
| SelectionMode="Multiple" | ||
| HeightRequest="300" | ||
| ItemsSource="{Binding Items}" | ||
| SelectedItems="{Binding SelectedItems}" | ||
| VerticalOptions="Center"> | ||
| <CollectionView.ItemsLayout> | ||
| <LinearItemsLayout Orientation="Horizontal" ItemSpacing="10"/> | ||
| </CollectionView.ItemsLayout> | ||
| <CollectionView.ItemTemplate> | ||
| <DataTemplate> | ||
| <Grid RowDefinitions="Auto,4" RowSpacing="5"> | ||
| <VisualStateManager.VisualStateGroups> | ||
| <VisualStateGroup x:Name="CommonStates"> | ||
| <VisualState x:Name="Normal"> | ||
| <VisualState.Setters> | ||
| <Setter Property="BackgroundColor" Value="Transparent"/> | ||
| <Setter TargetName="SelectedIndicator" Property="BoxView.IsVisible" Value="False"/> | ||
| </VisualState.Setters> | ||
| </VisualState> | ||
| <VisualState x:Name="Selected"> | ||
| <VisualState.Setters> | ||
| <Setter Property="BackgroundColor" Value="Transparent"/> | ||
| <Setter Property="Background" Value="Transparent"/> | ||
| <Setter TargetName="SelectedIndicator" Property="BoxView.IsVisible" Value="True"/> | ||
| </VisualState.Setters> | ||
| </VisualState> | ||
| </VisualStateGroup> | ||
| </VisualStateManager.VisualStateGroups> | ||
|
|
||
| <Label | ||
| Text="{Binding .}" | ||
| x:Name="ItemName" | ||
| FontAttributes="Bold" | ||
| FontSize="14" | ||
| VerticalOptions="Center" | ||
| HorizontalOptions="Center" | ||
| TextColor="Green"/> | ||
| <BoxView x:Name="SelectedIndicator" Color="blue" HeightRequest="4" HorizontalOptions="Fill" Grid.Row="1"/> | ||
| </Grid> | ||
| </DataTemplate> | ||
| </CollectionView.ItemTemplate> | ||
|
|
||
| </CollectionView> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.HostApp/Issues/Issue25551.xaml.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,26 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [Issue(IssueTracker.Github, 25551, "CollectionView SelectedItem binding issue on initial loading", | ||
| PlatformAffected.All)] | ||
| public partial class Issue25551 : ContentPage | ||
| { | ||
| public string SelectedItem { get; set; } | ||
|
|
||
| public ObservableCollection<string> Items { get; set; } | ||
| public List<object> SelectedItems { get; set; } | ||
|
|
||
| public Issue25551() | ||
| { | ||
| InitializeComponent(); | ||
| SelectedItems = new List<object>(); | ||
| Items = new ObservableCollection<string> { "A", "B", "C", "D", "E", "F" }; | ||
| SelectedItem = Items[0]; | ||
| SelectedItems.Add(Items[1]); | ||
| SelectedItems.Add(Items[3]); | ||
| BindingContext = this; | ||
| } | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25551.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,32 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using NUnit.Framework.Legacy; | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Tests.Issues | ||
| { | ||
| internal class Issue25551 : _IssuesUITest | ||
| { | ||
| public override string Issue => "CollectionView SelectedItem binding issue on initial loading"; | ||
|
|
||
| public Issue25551(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CollectionView)] | ||
|
|
||
| public void CollectionViewPreSelectionShouldUpdate() | ||
| { | ||
| App.WaitForElement("SingleSelection"); | ||
| VerifyScreenshot(); | ||
| App.WaitForElement("MultipleSelection"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| } | ||
Binary file added
BIN
+6.59 KB
...tCases.WinUI.Tests/snapshots/windows/CollectionViewPreSelectionShouldUpdate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58.1 KB
...ts/TestCases.iOS.Tests/snapshots/ios/CollectionViewPreSelectionShouldUpdate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.