Xamarin.Forms Guides | Samples

Xamarin.Forms.ListView.GroupShortNameBinding Property

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

Syntax

public BindingBase GroupShortNameBinding { get; set; }

Value

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

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 IEnumerable of each group to select the short name to display in the jump list.

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

Example

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 = 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" }
        }
  };
}

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0, 1.3.5.0, 1.4.0.0, 1.5.0.0, 2.0.0.0