The Xamarin.Forms.BindingBase instance to apply to grouped lists, or ..
This binding can be used to simply set a the text of the group headers without defining a full template and uses the default visuals of the platform to display it. The binding is applied to the IEnumerable of the group.
This property is mutually exclusive with ListView.GroupHeaderTemplate property. Setting it will set ListView.GroupHeaderTemplate to null.
This example shows an alphabetized list of people, grouped by first initial with the display 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" }
}
};
}