Created
May 17, 2017 15:07
-
-
Save stopiccot/a335f0029a0b80aba3e52690a5aa9a4e to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.ObjectModel; | |
using Xamarin.Forms; | |
using Xamarin.Forms.PlatformConfiguration; | |
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific; | |
namespace GroupingSampleListView | |
{ | |
public class GroupedListCode : ContentPage | |
{ | |
private ObservableCollection<GroupedVeggieModel> grouped { get; set; } | |
public GroupedListCode () | |
{ | |
var lstView = new Xamarin.Forms.ListView(); | |
grouped = new ObservableCollection<GroupedVeggieModel>(); | |
var letters = "mtwtfss"; | |
//letters += "mtwtfss"; letters += "mtwtfss"; letters += "mtwtfss"; | |
for (int i = 0; i < letters.Length; i++) { | |
string letter = letters[i].ToString(); | |
var group = new GroupedVeggieModel { LongName = letter.ToUpper() + " Section", ShortName = letter + letter }; | |
for (int j = 0; j < 20; j++) { | |
group.Add(new VeggieModel { Name = letter + " item " + j.ToString(), IsReallyAVeggie = true, Comment = "Comment" }); | |
} | |
grouped.Add(group); | |
} | |
lstView.ItemsSource = grouped; | |
lstView.IsGroupingEnabled = true; | |
lstView.GroupDisplayBinding = new Binding ("LongName"); | |
lstView.GroupShortNameBinding = new Binding ("ShortName"); | |
lstView.On<Android>().SetIsFastScrollEnabled(true); | |
lstView.ItemTemplate = new DataTemplate (typeof(TextCell)); | |
lstView.ItemTemplate.SetBinding (TextCell.TextProperty, "Name"); | |
// lstView.ItemTemplate.SetBinding (TextCell.DetailProperty, "Comment"); | |
Content = lstView; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment