Skip to content

Commit

Permalink
Cherry pick of #519
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbritch committed Oct 11, 2024
1 parent 3ae2170 commit 353b25b
Show file tree
Hide file tree
Showing 46 changed files with 195 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void AddCats()
Animals.Add(new Animal
{
Name = "Abyssinian",
Location = "Ethopia",
Location = "Ethiopia",
Details = "The Abyssinian is a breed of domestic short-haired cat with a distinctive tickedtabby coat, in which individual hairs are banded with different colors. The breed is named for Abyssinia (now called Ethiopia), where it is believed to have originated.",
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Gustav_chocolate.jpg/168px-Gustav_chocolate.jpg"
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void CreateAnimalsCollection()
new Animal
{
Name = "Abyssinian",
Location = "Ethopia",
Location = "Ethiopia",
Details = "The Abyssinian is a breed of domestic short-haired cat with a distinctive tickedtabby coat, in which individual hairs are banded with different colors. The breed is named for Abyssinia (now called Ethiopia), where it is believed to have originated.",
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Gustav_chocolate.jpg/168px-Gustav_chocolate.jpg"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@
OtherTemplate="{StaticResource BasicTemplate}" />
</ContentPage.Resources>

<StackLayout Margin="20">
<Grid RowDefinitions="Auto, *"
Margin="20">
<SearchBar x:Name="searchBar"
SearchCommand="{Binding FilterCommand}"
SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}"
Placeholder="Filter" />
<CollectionView ItemsSource="{Binding Monkeys}"
EmptyView="{Binding Source={x:Reference searchBar}, Path=Text}"
EmptyViewTemplate="{StaticResource SearchSelector}">
EmptyViewTemplate="{StaticResource SearchSelector}"
Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
Expand Down Expand Up @@ -71,5 +73,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.EmptyViewFilteredPage"
Title="EmptyView (string)">
<StackLayout Margin="20">
<Grid RowDefinitions="Auto, *"
Margin="20">
<SearchBar x:Name="searchBar"
SearchCommand="{Binding FilterCommand}"
SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}"
Placeholder="Filter" />
<CollectionView ItemsSource="{Binding Monkeys}"
EmptyView="No items match your filter.">
EmptyView="No items match your filter."
Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
Expand Down Expand Up @@ -38,5 +40,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.EmptyViewLoadSimulationPage"
Title="EmptyView (load simulation)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView x:Name="collectionView"
EmptyView="Loading items simulation.">
<CollectionView.ItemTemplate>
Expand Down Expand Up @@ -34,5 +34,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.EmptyViewNullPage"
Title="EmptyView (Null ItemsSource)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding EmptyMonkeys}"
EmptyView="No items to display" />
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@
</ContentView>
</ContentPage.Resources>

<StackLayout Margin="20">
<Grid RowDefinitions="Auto, Auto, *"
Margin="20">
<SearchBar x:Name="searchBar"
SearchCommand="{Binding FilterCommand}"
SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}"
Placeholder="Filter" />
<StackLayout Orientation="Horizontal">
<HorizontalStackLayout Grid.Row="1">
<Label Text="Toggle EmptyViews" />
<Switch Toggled="OnEmptyViewSwitchToggled" />
</StackLayout>
</HorizontalStackLayout>
<CollectionView x:Name="collectionView"
ItemsSource="{Binding Monkeys}">
ItemsSource="{Binding Monkeys}"
Grid.Row="2">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
Expand Down Expand Up @@ -70,5 +72,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
xmlns:controls="clr-namespace:CollectionViewDemos.Controls"
x:Class="CollectionViewDemos.Views.EmptyViewTemplatePage"
Title="EmptyView (template)">
<StackLayout Margin="20">
<Grid RowDefinitions="Auto, *"
Margin="20">
<SearchBar x:Name="searchBar"
SearchCommand="{Binding FilterCommand}"
SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}"
Placeholder="Filter" />
<CollectionView ItemsSource="{Binding Monkeys}">
<CollectionView ItemsSource="{Binding Monkeys}"
Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
Expand Down Expand Up @@ -51,5 +53,5 @@
</DataTemplate>
</CollectionView.EmptyViewTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.EmptyViewWithViewsFilteredPage"
Title="EmptyView (multiple views)">
<StackLayout Margin="20">
<Grid RowDefinitions="Auto, *"
Margin="20">
<SearchBar x:Name="searchBar"
SearchCommand="{Binding FilterCommand}"
SearchCommandParameter="{Binding Source={x:Reference searchBar}, Path=Text}"
Placeholder="Filter" />
<CollectionView ItemsSource="{Binding Monkeys}">
<CollectionView ItemsSource="{Binding Monkeys}"
Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
Expand Down Expand Up @@ -55,5 +57,5 @@
</ContentView>
</CollectionView.EmptyView>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalListEmptyGroupsPage"
Title="Grouping including empty groups">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Animals}"
IsGrouped="true">
<CollectionView.ItemTemplate>
Expand Down Expand Up @@ -48,5 +48,5 @@
</DataTemplate>
</CollectionView.GroupFooterTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalListGroupingPage"
Title="Grouping (with DataTemplates)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Animals}"
IsGrouped="true">
<CollectionView.ItemTemplate>
Expand Down Expand Up @@ -48,5 +48,5 @@
</DataTemplate>
</CollectionView.GroupFooterTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
xmlns:controls="clr-namespace:CollectionViewDemos.Controls"
x:Class="CollectionViewDemos.Views.VerticalListGroupingVariableSizeItemsPage"
Title="Grouping with variable sized items">
<StackLayout Margin="20">
<StackLayout Orientation="Horizontal"
HorizontalOptions="Center">
<Grid RowDefinitions="Auto, *"
Margin="20">
<HorizontalStackLayout HorizontalOptions="Center">
<Label Text="ItemSizingStrategy:"
VerticalTextAlignment="Center" />
<controls:EnumPicker x:Name="enumPicker"
EnumType="{x:Type ItemSizingStrategy}"
SelectedIndex="0" />
</StackLayout>
</HorizontalStackLayout>
<CollectionView ItemsSource="{Binding Animals}"
IsGrouped="true"
ItemSizingStrategy="{Binding Source={x:Reference enumPicker}, Path=SelectedItem}">
ItemSizingStrategy="{Binding Source={x:Reference enumPicker}, Path=SelectedItem}"
Grid.Row="1">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
Expand Down Expand Up @@ -56,7 +57,7 @@
</DataTemplate>
</CollectionView.GroupFooterTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalListTextGroupingPage"
Title="Grouping (without DataTemplates)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Animals}"
IsGrouped="true" />
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.HorizontalGridHeaderFooterViewPage"
Title="Grid header and footer (View)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
ItemsLayout="HorizontalGrid, 2">
<CollectionView.Header>
Expand Down Expand Up @@ -50,5 +50,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalListHeaderFooterDataTemplatePage"
Title="Header and footer (DataTemplate)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
Header="{Binding .}"
Footer="{Binding .}">
Expand Down Expand Up @@ -55,5 +55,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalListHeaderFooterStringPage"
Title="Header and footer (string)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
Header="Monkeys"
Footer="2019">
Expand Down Expand Up @@ -35,5 +35,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalListHeaderFooterViewPage"
Title="Header and footer (View)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}">
<CollectionView.Header>
<StackLayout BackgroundColor="LightGray">
Expand Down Expand Up @@ -49,5 +49,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.HorizontalGridPage"
Title="Horizontal grid (DataTemplate)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
ItemsLayout="HorizontalGrid, 4">
<CollectionView.ItemTemplate>
Expand Down Expand Up @@ -36,5 +36,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.HorizontalGridTextPage"
Title="Horizontal grid (text)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsLayout="HorizontalGrid, 4">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
Expand All @@ -27,5 +27,5 @@
</x:Array>
</CollectionView.ItemsSource>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.HorizontalListPage"
Title="Horizontal list (DataTemplate)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
ItemsLayout="HorizontalList">
<CollectionView.ItemTemplate>
Expand Down Expand Up @@ -36,5 +36,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.HorizontalListTextPage"
Title="Horizontal list (text)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsLayout="HorizontalList">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
Expand All @@ -27,5 +27,5 @@
</x:Array>
</CollectionView.ItemsSource>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CollectionViewDemos.Views.VerticalGridPage"
Title="Vertical grid (DataTemplate)">
<StackLayout Margin="20">
<Grid Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
ItemsLayout="VerticalGrid, 2">
<CollectionView.ItemTemplate>
Expand Down Expand Up @@ -36,5 +36,5 @@
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</Grid>
</ContentPage>
Loading

0 comments on commit 353b25b

Please sign in to comment.