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.
Correction of CollectionView to work properly with selected item color (
#12651) fixes #7790 fixes #9590 fixes #11421 * Correction of CollectionView to work properly with selected item color when using VisualState on Android and iOS * Update TemplatedCell.cs * Update TemplatedItemViewHolder.cs * Add scaling to make the bug more obvious * Make fix work for on-template visual states on iOS * Make fix for for on-template visual states on Android * Minor performance optimization * Make method name more explicit * Spaces -> Tabs * Fix UI test failure (item 3 doesn't fit on the screen anymore) Co-authored-by: Rony Mesquita <ronymesquitadasilva@gmail.com>
- Loading branch information
1 parent
75ca48d
commit 6355a1d
Showing
5 changed files
with
170 additions
and
39 deletions.
There are no files selected for viewing
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
104 changes: 73 additions & 31 deletions
104
...ontrols/GalleryPages/CollectionViewGalleries/SelectionGalleries/SingleBoundSelection.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 |
---|---|---|
@@ -1,33 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.SelectionGalleries.SingleBoundSelection"> | ||
<ContentPage.Content> | ||
<StackLayout Spacing="5"> | ||
|
||
<Label Text="The selected item in the CollectionView should match the 'Selected' Label below. If it does not, this test has failed." | ||
VerticalOptions="CenterAndExpand" | ||
HorizontalOptions="CenterAndExpand" /> | ||
|
||
<Label Text="{Binding SelectedItem, StringFormat='{}Selected: {0}'}" | ||
VerticalOptions="CenterAndExpand" | ||
HorizontalOptions="CenterAndExpand" /> | ||
|
||
<Button AutomationId="Reset" Text="Reset Selection to Item 0" Clicked="ResetClicked" /> | ||
|
||
<Button AutomationId="Clear" Text="Clear Selection" Clicked="ClearClicked" /> | ||
|
||
<CollectionView ItemsSource="{Binding Items}" SelectionMode="Single" SelectedItem="{Binding SelectedItem}"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout> | ||
<Image Source="{Binding Image}" HeightRequest="50" /> | ||
<Label Text="{Binding Caption}"></Label> | ||
</StackLayout> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
|
||
</StackLayout> | ||
</ContentPage.Content> | ||
<ContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.SelectionGalleries.SingleBoundSelection"> | ||
|
||
<ContentPage.Content> | ||
<StackLayout | ||
Spacing="5"> | ||
|
||
<Label | ||
Text="The selected item in the CollectionView should match the 'Selected' Label below. If it does not, this test has failed." | ||
VerticalOptions="CenterAndExpand" | ||
HorizontalOptions="CenterAndExpand" /> | ||
|
||
<Label | ||
Text="{Binding SelectedItem, StringFormat='{}Selected: {0}'}" | ||
VerticalOptions="CenterAndExpand" | ||
HorizontalOptions="CenterAndExpand" /> | ||
|
||
<Button | ||
AutomationId="Reset" | ||
Text="Reset Selection to Item 0" | ||
Clicked="ResetClicked" /> | ||
|
||
<Button | ||
AutomationId="Clear" | ||
Text="Clear Selection" | ||
Clicked="ClearClicked" /> | ||
|
||
<CollectionView | ||
ItemsSource="{Binding Items}" | ||
SelectionMode="Single" | ||
SelectedItem="{Binding SelectedItem}"> | ||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Frame | ||
HasShadow="False" | ||
Margin="10" | ||
BackgroundColor="LightBlue" | ||
CornerRadius="20"> | ||
<StackLayout> | ||
<Image | ||
Source="{Binding Image}" | ||
HeightRequest="50" /> | ||
<Label | ||
Text="{Binding Caption}"></Label> | ||
</StackLayout> | ||
|
||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroupList> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal" /> | ||
<VisualState x:Name="Selected"> | ||
<VisualState.Setters> | ||
<Setter | ||
Property="BackgroundColor" | ||
Value="RoyalBlue" /> | ||
<Setter | ||
Property="Scale" | ||
Value="0.9" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateGroupList> | ||
</VisualStateManager.VisualStateGroups> | ||
|
||
</Frame> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
|
||
</StackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
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
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