This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] CollectionView not applying "Selected" VisualState to pre-selec…
…ted items (#14672) * Fix issue setting initial selected VisualState in iOS CollectionView * Updated the issue steps
- Loading branch information
1 parent
be2471c
commit 8fcf863
Showing
4 changed files
with
127 additions
and
9 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue14513.xaml
This file contains 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,40 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<local:TestContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://xamarin.com/schemas/2014/forms/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Title="Test 14513" xmlns:local="using:Xamarin.Forms.Controls" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue14513"> | ||
<StackLayout | ||
Padding="12"> | ||
<Label | ||
Text="If the selected item have a Red background, the test has passed."/> | ||
<CollectionView | ||
ItemsSource="{Binding Items}" | ||
SelectedItem="{Binding SelectedItem}" | ||
SelectionMode="Single"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Grid> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup Name="CommonStates"> | ||
<VisualState Name="Normal" /> | ||
<VisualState Name="Selected"> | ||
<VisualState.Setters> | ||
<Setter Property="BackgroundColor" Value="Red" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
<Label | ||
x:Name="Title" | ||
Text="{Binding Name}" | ||
FontSize="Large" /> | ||
</Grid> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</StackLayout> | ||
</local:TestContentPage> |
68 changes: 68 additions & 0 deletions
68
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue14513.xaml.cs
This file contains 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,68 @@ | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using System.Collections.ObjectModel; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
#if UITEST | ||
[Category(UITestCategories.CollectionView)] | ||
#endif | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 14513, | ||
"[Bug] [iOS] SelectedItems custom image not displaying in iOS for CollectionView until tapped", | ||
PlatformAffected.iOS)] | ||
public partial class Issue14513 : TestContentPage | ||
{ | ||
public Issue14513() | ||
{ | ||
#if APP | ||
InitializeComponent(); | ||
#endif | ||
} | ||
|
||
protected override void Init() | ||
{ | ||
BindingContext = new Issue14513ViewModel(); | ||
} | ||
} | ||
|
||
public class Issue14513Model | ||
{ | ||
public string Name { get; set; } | ||
} | ||
|
||
public class Issue14513ViewModel : BindableObject | ||
{ | ||
Issue14513Model _selectedItem; | ||
|
||
public Issue14513ViewModel() | ||
{ | ||
Items = new ObservableCollection<Issue14513Model> | ||
{ | ||
new Issue14513Model { Name = "Item 1" }, | ||
new Issue14513Model { Name = "Item 2" }, | ||
new Issue14513Model { Name = "Item 3" } | ||
}; | ||
|
||
SelectedItem = Items[1]; | ||
} | ||
|
||
public ObservableCollection<Issue14513Model> Items { get; set; } | ||
|
||
public Issue14513Model SelectedItem | ||
{ | ||
get { return _selectedItem; } | ||
set | ||
{ | ||
_selectedItem = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
} |
This file contains 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 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