Freigeben über


ListView.GroupShortNameBinding Property

Definition

Gets or sets a binding for the name to display in grouped jump lists.

public Xamarin.Forms.BindingBase GroupShortNameBinding { get; set; }
member this.GroupShortNameBinding : Xamarin.Forms.BindingBase with get, set

Property Value

The BindingBase instance to apply to grouped lists, or null.

Examples

This example shows an alphabetized list of people, grouped by first initial with the short name binding set.

class Person
{
  public string FullName
  {
    get;
    set;
  }

  public string Address
  {
    get;
    set;
  }
}
class Group : ObservableCollection<Person>
{
  public Group (string firstInitial)
  {
    FirstInitial = firstInitial;
  }

  public string FirstInitial
  {
    get;
    private set;
  }
}
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 = template;
  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" }
        }
  };
}

Remarks

When grouping items in a 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 System.Collections.IEnumerable of each group to select the short name to display in the jump list.

Note: On Android, there is no displayed jump list.

Applies to