ListView.GroupDisplayBinding プロパティ

定義

グループ ヘッダーの表示に使用するバインディングを取得または設定します。

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

プロパティ値

BindingBase

グループ化された BindingBase リストに適用するインスタンス、または null

次の例では、最初に表示バインドセットを使用してグループ化された、ひとのアルファベット順の一覧を示します。

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

注釈

このバインディングを使用すると、完全なテンプレートを定義せずに、グループヘッダーのテキストを簡単に設定し、プラットフォームの既定のビジュアルを使用して表示することができます。 バインドは、グループのに適用され IEnumerable ます。

このプロパティは、プロパティと同時には使用 GroupHeaderTemplate できません。 設定すると、がに設定され GroupHeaderTemplate null ます。

適用対象