title: Xamarin ListView not displaying any data
body: <p>I have a problem where I'm trying to display data inside a <code>ListView</code> in my app when binding a list of data to my ListView in XAML. The ListView does not populate with any data at all.</p>
  
  <p>Here is all my coding:</p>
  
  <p>My <strong><em>Code-behind</em></strong></p>
  
  <pre><code>public ObservableCollection&lt;RandomList&gt; randomList = new ObservableCollection&lt;RandomList&gt;();
  
  public App()
  {
      MainPage = new MainUI();
  
      randomList.Add(new RandomList { Name = "Susan", Surname = "Potgieter", School = "Oosterlig" });
      randomList.Add(new RandomList { Name = "Jonathan", Surname = "Visagie", School = "Elspark" });
      randomList.Add(new RandomList { Name = "Gerhard", Surname = "Vermaak", School = "E.G. Jansen" });
      randomList.Add(new RandomList { Name = "Kobus", Surname = "Jacobs", School = "Oosterlig" });          
  }
  </code></pre>
  
  <p>My <strong><em>XAML</em></strong></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="RandomTest.MainUI"&gt;
    &lt;StackLayout Padding="0,40,0,0"&gt;
      &lt;Label Text="Hello" VerticalOptions="Center" HorizontalOptions="Center" /&gt;
      &lt;Button x:Name="btnGetStudents" Text="Get Students"/&gt;
      &lt;ListView x:Name="lwStudents" ItemsSource="{Binding randomList}"&gt;
        &lt;ListView.ItemTemplate&gt;
          &lt;DataTemplate&gt;
            &lt;TextCell Text="{Binding Name}" Detail="{Binding Surname}"/&gt;
          &lt;/DataTemplate&gt;
        &lt;/ListView.ItemTemplate&gt; 
      &lt;/ListView&gt;
    &lt;/StackLayout&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p>When I insert a breakpoint in my code behind where I add the dummy data to the list, I can then see in my XAML here: <code>&lt;ListView x:Name="lwStudents" ItemsSource="{Binding randomList}"&gt;</code> that there are 4 items in my <code>randomList</code>.</p>
  
  <p>The problem is that there is no data in the two bindings below:</p>
  
  <pre><code>&lt;TextCell Text="{Binding Name}" Detail="{Binding Surname}"/&gt;
  </code></pre>
  
  <p>Can someone please tell or show me what I'm doing wrong in my binding? Or if you need ANY more info or code, please ask! I will be happy to give more info. :)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I've updated my <code>RandomList</code> class and implemented <code>INotifyPropertyChanged</code>, but I still can't get my data to load in my ListView through XAML bindings.</p>
  
  <pre><code>using System.ComponentModel;
  
  namespace RandomTest
  {
      public class RandomList : INotifyPropertyChanged
      {
          public int Id { get; set; }
  
          string _name;
          public string Name
          {
              get { return _name; }
              set
              {
                  if (_name != value)
                      _name = value;
                  OnPropertyChanged("Name");
              }
          }
  
          string _surname;
          public string Surname
          {
              get { return _surname; }
              set
              {
                  if (_surname != value)
                      _surname = value;
                  OnPropertyChanged("Surname");
              }
          }
  
          string _school;
          public string School
          {
              get { return _school; }
              set
              {
                  if (_school != value)
                      _school = value;
                  OnPropertyChanged("School");
              }
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
          void OnPropertyChanged(string propertyName)
          {
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>This is how my MainUI.xaml.cs page looks like at the moment:</p>
  
  <pre><code>public partial class MainUI : ContentPage
  {
      public MainUI()
      {
          InitializeComponent();
          BindingContext = new MainUIModel();
  
          MainUIModel mainUIModel = (MainUIModel)this.BindingContext;
          mainUIModel.randomList.Add(new RandomList { Name = "Susan", Surname = "Potgieter", School = "Oosterlig" });
          mainUIModel.randomList.Add(new RandomList { Name = "Jonathan", Surname = "Visagie", School = "Elspark" });
          mainUIModel.randomList.Add(new RandomList { Name = "Gerhard", Surname = "Vermaak", School = "E.G. Jansen" });
          mainUIModel.randomList.Add(new RandomList { Name = "Kobus", Surname = "Jacobs", School = "Oosterlig" });
      }
  }
  </code></pre>