title: Xamarin Collectionview Binding Not working
body: <p>I have a problem where I am using a collectionview and I am trying to get the bindings to work.
  I have tried to set the Height, as I saw in other posts, by setting the miniumheight and heightrequest of every element involved, with no success. I have a listview with a textcell and that is the only way I can get this to work.</p>
  <p>Model</p>
  <pre><code>    [Table(&quot;Category&quot;)]
      public class Category
      {
          [PrimaryKey, AutoIncrement]
          public int Id { get; set; }
          public string Name { get; set; }
      }
  </code></pre>
  <p>ViewModel</p>
  <pre><code>    public class CategoriesViewModel : BaseViewModel
      {
          public ObservableCollection&lt;Category&gt; Categories { get; }
          public Command LoadCategoriesCommand { get; }
          public Command AddCategoryCommand { get; }
  
          public CategoriesViewModel()
          {
              Title = &quot;Categories&quot;;
              Categories = new ObservableCollection&lt;Category&gt;();
              LoadCategoriesCommand = new Command(async () =&gt; await ExecuteLoadCategoriesCommand());
  
              AddCategoryCommand = new Command(OnAddCategory);
          }
  
          async Task ExecuteLoadCategoriesCommand()
          {
              IsBusy = true;
  
              try
              {
                  Categories.Clear();
                  var categories = await DataStore.GetCategoriesAsync();
                  foreach (var cat in categories)
                  {
                      Categories.Add(cat);
                  }
              }
              catch (Exception ex)
              {
                  Debug.WriteLine(ex);
                  Debug.WriteLine(ex.Message);
              }
              finally
              {
                  IsBusy = false;
              }
          }
  
          public void OnAppearing()
          {
              IsBusy = true;
          }
  </code></pre>
  <p>View</p>
  <pre><code>             xmlns:local=&quot;clr-namespace:FreeScanner.ViewModels&quot;
               xmlns:model=&quot;clr-namespace:FreeScanner.Models&quot;
               x:Name=&quot;BrowseCategoriesPage&quot;&gt;
  
      &lt;ContentPage.ToolbarItems&gt;
          &lt;ToolbarItem Text=&quot;Add&quot; Command=&quot;{Binding AddCategoryCommand}&quot; /&gt;
      &lt;/ContentPage.ToolbarItems&gt;
      &lt;RefreshView x:DataType=&quot;local:CategoriesViewModel&quot; Command=&quot;{Binding LoadCategoriesCommand}&quot;
                   IsRefreshing=&quot;{Binding IsBusy, Mode=TwoWay}&quot;&gt;
          &lt;CollectionView x:Name=&quot;CategoriesListView&quot;
                          ItemsSource=&quot;{Binding Categories}&quot;&gt;
              &lt;CollectionView.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid Padding=&quot;10&quot; x:DataType=&quot;model:Category&quot;&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height=&quot;Auto&quot; /&gt;
                              &lt;RowDefinition Height=&quot;Auto&quot; /&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width=&quot;Auto&quot; /&gt;
                              &lt;ColumnDefinition Width=&quot;Auto&quot; /&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;Label Grid.Column=&quot;1&quot;
                                 Grid.Row=&quot;1&quot;
                                 Text=&quot;{Binding Name}&quot;
                                 FontAttributes=&quot;Bold&quot; /&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/CollectionView.ItemTemplate&gt;  
          &lt;/CollectionView&gt;
          &lt;!--&lt;ListView ItemsSource=&quot;{Binding Categories}&quot; 
                    x:Name=&quot;CategoriesListView&quot;
                    SelectionMode=&quot;None&quot;
                    RowHeight=&quot;50&quot;&gt;
              &lt;ListView.ItemTemplate&gt;
                  &lt;DataTemplate x:DataType=&quot;model:Category&quot;&gt;
                      &lt;TextCell Text=&quot;{Binding Name}&quot;/&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListView.ItemTemplate&gt;
          &lt;/ListView&gt;--&gt;
      &lt;/RefreshView&gt;
  </code></pre>
  <p>When I debug and hover over the CollectView ItemSource Categories I do see the Count = 1 and I can verify that is correctly loading from the database.</p>
  <p><a href="https://i.stack.imgur.com/EtstY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EtstY.jpg" alt="Screenshot of Page" /></a></p>