GroupDisplayBinding attribute causes the ListView.ItemTemplate to disappear


I’m trying to implement a very simple ListView grouped by an Id value. In my page constructor I’ve something like this:

    public CheckApparatusProgressPage(CheckReport checkReport, Apparatus currentApparatus)
        CurrentCheckReport  checkReport;
        CurrentApparatus  currentApparatus;
        Title  "Check";
        var itemsSource  App.RestClient.GetCheckReportOutcome(CurrentApparatus.Id).Result;
        GroupedView.ItemsSource  itemsSource;

itemsSource is a List<ApparatusCheckStepOutcome> that class looks like this:

public class ApparatusCheckStepOutcome
    public ApparatusCheckStep ApparatusCheckStep { set; get; }
    public string Comment { get; set; }
    public DateTime CreatedAt { get; set; }
    public int Id { get; set; }
    public bool Passing { get; set; }

And the ApparatusCheckStep class looks like this:

public class ApparatusCheckStep
    public string Category { get; set; }
    public DateTime CreatedAt { get; set; }
    public string Description { get; set; }
    public int Id { get; set; }
    public string Name { get; set; }
    public int Weight { get; set; }

Basically I need to show in my group headers the value of {Binding ApparatusCheckStep.Id} and in the children within that group two Labels with {Binding ApparatusCheckStep.Name} and {Binding ApparatusCheckStep.Description} each one.

This is my XAML view:

<?xml version"1.0" encoding"UTF-8"?>
<ContentPage xmlns""
      <ListView x:Name"GroupedView" IsGroupingEnabled"True" GroupDisplayBinding"{Binding ApparatusCheckStep.Id}">
      <!-- Single Row Customization -->
              <StackLayout Orientation"Horizontal" HorizontalOptions"FillAndExpand" >
                <Label Text"{Binding ApparatusCheckStep.Name}" FontSize"12" TextColor"White" />
                <Label Text"{Binding ApparatusCheckStep.Description}" FontSize"12" TextColor"White" />

I tried everything and I seached lot, if I remove the IsGroupingEnabled and GroupDisplayBinding attributes from the ListView I see all the “Name – Description” rows without any header grouping them. If I leave those attributes I only see the Id header rows, and the ListView.ItemTemplate seems to be totally ignored.

What I’m doing wrong? I want to keep this as simple as possible, that’s why I’m trying to do most of the work with XAML, and I’d like to keep it that way.


when you use grouping, you need to have your ItemSource in a certain way – you essentially have to have one IEnumerable containing the groups, each of which in turn contains another IEnumerable containing the data for each group

Xamarin has a sample app that demonstrates how to do this; or there is another excellent example here (dead link, here’s an archived version)

Answered By – Jason

Leave a Comment