次の方法で共有


ListView.GroupDisplayBinding Property

Definition

Gets or sets the binding to use for displaying the group header.

public:
 property Microsoft::Maui::Controls::BindingBase ^ GroupDisplayBinding { Microsoft::Maui::Controls::BindingBase ^ get(); void set(Microsoft::Maui::Controls::BindingBase ^ value); };
public Microsoft.Maui.Controls.BindingBase GroupDisplayBinding { get; set; }
member this.GroupDisplayBinding : Microsoft.Maui.Controls.BindingBase with get, set
Public Property GroupDisplayBinding As BindingBase

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 display 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

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 GroupHeaderTemplate property. Setting it will set GroupHeaderTemplate to null.

Applies to