title: Populating a grouped ListView from a list
body: <p>I have a big list of objects retrieved through parsing a JSON file. Right now I'm binding said list to a <code>ListView</code> but the list is unwieldy and I wanted to divide it in separate groups for an ease of use. I tried following several different guides but I'm unable to prepare my data in the correct way. If I manually initialize one of my sorted lists with some items they do show up so the code is indeed functioning. </p>
  
  <p>My grouping model:</p>
  
  <pre><code>public class SortedItem
  {
      public string Header { get; set; }
      public List&lt;Item&gt; Items { get; set; }
  
      public SortedItem(string header)
      {
          Header = header;
      }
  }
  </code></pre>
  
  <p>My object model:</p>
  
  <pre><code>public class Item
  {
      public string item { get; set; }
      //public int icon { get; set; }
  
      private string ico;
      public string icon
      {
          get { return ico; }
          set { ico = "Icons/" + value + ".png"; }
      }
  
      public int id { get; set; }
      public string slot { get; set; }
      public string scrip { get; set; }
      public Reduce reduce { get; set; }
      public int lvl { get; set; }
      public string zone { get; set; }
      public int time { get; set; }
  }
  </code></pre>
  
  <p>Right now my XAML is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       x:Class="Eorzea_Gatherer.Pages.NodesPage"
       xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" 
       ios:Page.UseSafeArea="true"
       BackgroundColor="#F4F4F4"&gt;
  &lt;!--https://xamarinhelp.com/safeareainsets-xamarin-forms-ios/--&gt;
  &lt;ListView x:Name="nodesListView"
        IsGroupingEnabled="True"
        GroupDisplayBinding="{Binding Header}"
        HasUnevenRows="True"
        BackgroundColor="#F4F4F4"
        Margin="30, 30, 30, 0"&gt;
  &lt;ListView.ItemTemplate&gt;
      &lt;DataTemplate&gt;
          &lt;ViewCell&gt;
              &lt;Grid Padding="0, 5"&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition Width="60"/&gt;
                      &lt;ColumnDefinition/&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Image Source="{Binding icon}"
                         HeightRequest="50"
                         WidthRequest="50"
                         Grid.Column="0"/&gt;
                  &lt;StackLayout Grid.Column="1"&gt;
                      &lt;Label Text="{Binding item}"
                             TextColor="#171717"
                             FontSize="13"
                             FontFamily="SegoeUI"/&gt;
                      &lt;!--https://forums.xamarin.com/discussion/97996/binding-more-than-one-property-in-listview--&gt;
                      &lt;Label TextColor="#171717"
                             FontSize="12"
                             FontFamily="SegoeUI"&gt;
                          &lt;Label.FormattedText&gt;
                              &lt;FormattedString&gt;
                                  &lt;Span Text="{Binding zone}"/&gt;
                                  &lt;Span Text=" - "/&gt;
                                  &lt;Span Text="{Binding slot}"/&gt;
                              &lt;/FormattedString&gt;
                          &lt;/Label.FormattedText&gt;
                      &lt;/Label&gt;
                      &lt;Label TextColor="#171717"
                             FontSize="12"
                             FontFamily="SegoeUI"&gt;
                          &lt;Label.FormattedText&gt;
                              &lt;FormattedString&gt;
                                  &lt;Span Text="{Binding time}"/&gt;
                                  &lt;Span Text=" - "/&gt;
                                  &lt;Span Text="00:00 AM"/&gt;
                              &lt;/FormattedString&gt;
                          &lt;/Label.FormattedText&gt;
                      &lt;/Label&gt;
                  &lt;/StackLayout&gt;
              &lt;/Grid&gt;
          &lt;/ViewCell&gt;
      &lt;/DataTemplate&gt;
  &lt;/ListView.ItemTemplate&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>The function I'm using to retrieve the list and to bind it as a source to the ListView:</p>
  
  <pre><code>public static List&lt;SortedItem&gt; GetSortedItems()
  {
      List&lt;Item&gt; items = GetItems();
  
      List&lt;SortedItem&gt; sortedItems = new List&lt;SortedItem&gt;()
      {
          new SortedItem("50")
          {
             Items = items.Where(x =&gt; x.lvl == 50).ToList()
          },
          new SortedItem("55"),
          new SortedItem("60"),
          new SortedItem("65"),
          new SortedItem("70")
      };
  
      return sortedItems;
  }
  </code></pre>
  
  <p>With my code I'm able to see the different groups in my ListView (50, 55, ...) but nothing else pops out. I'm sure my issue is taking my objects list and splitting it in an appropriate way but I'm stumped. What puzzles me is during debugging when hovering on the resulting <code>sortedItems</code> I get to see my first group does contain the objects it needs to but they still don't show up in the view.</p>