the readonly variable _reservations needs to be assigned in the constructor or definition.
private readonly ObservableCollection<ReservationViewModel> _reservations = new();
or
public ReservationListingViewModel()
{
_reservations = new ObservableCollection<ReservationViewModel>();
InitializeAsync();
}
also as GetReservations() has a couple issues
- as _reservations is readonly it can not be set in his method
- there is no async code, not sure why its a Task.
- as ObservableCollection's do not implement thread concurrency, if you wanted an async load, you will need to add some synchronization logic to call from constructor, as the constructor can not wait for completion. and a user of the class should not access until the load is complete.