title: How to fix an empty listview in xamarin.forms mobile app page
body: <p>I am learning to use Xamarin.Forms with prism, I want to populate a list view with a specific item from each object in my list. My list view shows up empty, but I don't see any errors.</p>
  
  <p>I have tried using binding to bind to the Name variables in my objects, in my list. That showed up empty so I tried using Observable Collection to get my list and add each Name.</p>
  
  <p>This is the Animal object model</p>
  
  <pre><code>using System;
  namespace LearningPrism.Models
  {
      class Animal
      {
          public string Name { get; set; }
          public int Age { get; set; }
          public decimal Happiness { get; set; }
  
          public void PrintBase()
          {
              Console.WriteLine($"Name: {Name}");
              Console.WriteLine($"Age: {Age}");
              Console.WriteLine($"Happy: {Happiness}");
              Console.WriteLine();
          }
      }
  }
  </code></pre>
  
  <p>I create my list using the Breed class as the object and have 3 functions bellow which get the filtered list for the type (unfiltered for get all breeds).</p>
  
  <pre><code>namespace LearningPrism.Models
  {
      class Breed
      {
  
          public static List&lt;Animal&gt; _breedList = new List&lt;Animal&gt;
              {
                  new Animal
                  {
                      Id = Guid.NewGuid().ToString(),
                      Name = "Greyhound",
                      Type = BreedType.Dog
                  },
  
  //There are 3 more Dog Animal breeds but I have removed them so it is easier to read
  
                  new Animal
                  {
                      Id = Guid.NewGuid().ToString(),
                      Name = "Bengal",
                      Type = BreedType.Cat
                  }, 
  
  //There are 3 more Cat Animal breeds but I have removed them so it is easier to read
  
                  }
              };
  
          public static List&lt;Animal&gt; GetAllBreeds()
          {
              return _breedList;
          }
  
          public static List&lt;Animal&gt; GetBreedsByType(BreedType type)
          {
  
              switch (type)
              {
                  case BreedType.Dog:
                      return (from Animal in _breedList where Animal.Type == BreedType.Dog select Animal).ToList();
  
                  case BreedType.Cat:
                      return (from Animal in _breedList where Animal.Type == BreedType.Cat select Animal).ToList();
  
                  default:
                      return _breedList;
  
              }
          }
      }
  }
  
  </code></pre>
  
  <p>Here is my view model:</p>
  
  <pre><code>namespace LearningPrism.ViewModels
  {
      public class PageAViewModel : ViewModelBase
      {
          private List&lt;Breed&gt; MyList { get; set; }
  
          public PageAViewModel(INavigationService navigationService) : base(navigationService)
          {
              Title = "Hello Human";
          }
  
          private void LoadData()
          {
  
              ObservableCollection&lt;Animal&gt; myData = new ObservableCollection&lt;Animal&gt;(Breed.GetAllBreeds() as List&lt;Animal&gt;);
  
          }
  
          public override void OnNavigatingTo(INavigationParameters parameters)
          {
              base.OnNavigatingTo(parameters);
  
              LoadData();
          }
      }
  }
  
  </code></pre>
  
  <p>Here is the XAML code for the page</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"
               xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
               prism:ViewModelLocator.AutowireViewModel="True"
               x:Class="LearningPrism.Views.PageA" Title="{Binding Title}"&gt;
  
      &lt;Label Text="{Binding Title}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" /&gt;
  
      &lt;StackLayout&gt;
  
          &lt;ListView HorizontalOptions="FillAndExpand" 
                    VerticalOptions="FillAndExpand" 
                    ItemsSource="{Binding myData}"&gt;
  
              &lt;ListView.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;StackLayout HorizontalOptions="CenterAndExpand"&gt;
                          &lt;Label Text="{Binding Breed.Name}" TextColor="Black"&gt;&lt;/Label&gt;
                      &lt;/StackLayout&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListView.ItemTemplate&gt;
  
          &lt;/ListView&gt;
  
      &lt;/StackLayout&gt;
  
  &lt;/ContentPage&gt;
  </code></pre>