0

Following this tutorial: https://docs.microsoft.com/pl-pl/xamarin/xamarin-forms/user-interface/listview/data-and-databinding

i'm getting this exeption:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

in line: CategoryListView.ItemsSource = _category;

in the tutorial there is a warning which i guess is assiocciated with my problem, but i still have no clue how to solve the problem(i don't fully understand the warning)

namespace EduApp { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class QUIZListViewPage : ContentPage

{
   ObservableCollection<Category> _category = new ObservableCollection<Category>();
    //public ObservableCollection<Category> _Category { get { return _category; } }


    public QUIZListViewPage()

    {


        CategoryListView.ItemsSource = _category;

        _category.Add(new Category { categoryName = "first" });


        InitializeComponent();
    }
}

}

TY in advanced C:

Pickle
  • 9
  • 3
  • 2
    to start with `InitializeComponent` should be the first thing in your constructor. – Jason Sep 20 '19 at 20:11
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Ken White Sep 20 '19 at 21:00

0 Answers0