Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,11 @@
<Name>CollectionViewChallenge</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\iphone6.jpeg" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\star.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
<Folder Include="ViewModels\" />
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions CollectionViewChallenge/CollectionViewChallenge/Models/ListItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;

namespace CollectionViewChallenge.Models
{
public class ListItem
{
public string Title { get; set; }
public string Description { get; set; }
public string Price { get; set; }
public string Percentage { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,53 @@
mc:Ignorable="d"
x:Class="CollectionViewChallenge.Views.CollectionViewChallengePage">
<ContentPage.Content>
<StackLayout>
<StackLayout BackgroundColor="White">
<!-- Use your own layout and functionality here! -->
<CollectionView>
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>This is a CollectionView!</x:String>
<x:String>Your feedback on the experience of converting a ListView to a CollectionView is incredibly appreciated.</x:String>
<x:String>Here are three general questions:</x:String>
<x:String>1. How was the experience of converting your existing ListView to a CollectionView?</x:String>
<x:String>2. How is the performance compared to the ListView?</x:String>
<x:String>3. Is there a specific piece of functionality that you'd like to see?</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView x:Name="collectionList" Margin="10">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="5">
<Label Text="{Binding .}" d:Text="Design Time Data" FontSize="10"/>
</StackLayout>
<Grid Padding="10" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Frame BackgroundColor="White" Grid.RowSpan="2" CornerRadius="5" Padding="10">
<Image
Source="iphone6.jpeg"
Aspect="AspectFill"
HeightRequest="100"
WidthRequest="100" />
</Frame>
<Label Grid.Column="1"
Text="{Binding Title}"
FontAttributes="Bold" />
<Label Margin="0,20,0,0" Grid.Column="1"
Text="{Binding Description}"
FontAttributes="Bold" />
<Label Grid.Row="1"
Grid.Column="1"
Text="{Binding Price}"
VerticalOptions="End" />
<Frame Grid.Row="0"
Grid.Column="2" BackgroundColor="Pink" Padding="10">
<Label TextColor="White"
Text="{Binding Percentage}"
VerticalOptions="Start" />
</Frame>

<Image Grid.Row="1" Grid.Column="2"
Source="star.png"
HeightRequest="5"
WidthRequest="5" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>

</CollectionView>
</StackLayout>
</ContentPage.Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using CollectionViewChallenge.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -16,5 +17,20 @@ public CollectionViewChallengePage()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();

List<ListItem> listItems = new List<ListItem>();
ListItem listItem = new ListItem() {Title="iPhone",Description="2GB RAM, 16GB Internal", Price="$500" ,Percentage="50%"};
ListItem listItem1 = new ListItem() { Title = "iPhone", Description = "2GB RAM, 16GB Internal", Price = "$500", Percentage = "50%" };
ListItem listItem2 = new ListItem() { Title = "iPhone", Description = "2GB RAM, 16GB Internal", Price = "$500", Percentage = "50%" };
ListItem listItem3 = new ListItem() { Title = "iPhone", Description = "2GB RAM, 16GB Internal", Price = "$500", Percentage = "50%" };
listItems.Add(listItem);
listItems.Add(listItem1);
listItems.Add(listItem2);
listItems.Add(listItem3);
collectionList.ItemsSource = listItems;
}
}
}