The Xamarin.Forms.BindingBase instance to apply to grouped lists, or ..
When grouping items in a Xamarin.Forms.ListView, it is often useful to have jump lists to jump to specific sections in the list. For example, in an alphabetically grouped lists, the jump list would be the the letter of each group. This binding is applied against the IEnumerable of each group to select the short name to display in the jump list.
Note: On Android, there is no displayed jump list.
This example shows an alphabetized list of people, grouped by first initial with the short name binding set.
C# Example
class Person
{
public string FullName
{
get;
set;
}
public string Address
{
get;
set;
}
}
C# Example
class Group : ObservableCollection<Person>
{
public Group (string firstInitial)
{
FirstInitial = firstInitial;
}
public string FirstInitial
{
get;
private set;
}
}
C# Example
ListView CreateListView()
{
var listView = new ListView {
IsGroupingEnabled = true,
GroupDisplayBinding = new Binding ("FirstInitial"),
GroupShortNameBinding = new Binding ("FirstInitial")
};
var template = new DataTemplate (typeof (TextCell));
template.SetBinding (TextCell.TextProperty, "FullName");
template.SetBinding (TextCell.DetailProperty, "Address");
itemsView.ItemTemplate = temeplate;
itemsView.ItemsSource = new[] {
new Group ("C") {
new Person { FullName = "Caprice Nave" }
},
new Group ("J") {
new Person { FullName = "James Smith", Address = "404 Nowhere Street" },
new Person { FullName = "John Doe", Address = "404 Nowhere Ave" }
}
};
}