Hi,
I'm trying to load data async to an sfDataGrid but I get a null reference exception and I can't understand why. Essentially, I'm populating the sfDataGrid with an ObservableCollection. This observablecollection gets its data through an async method that returns a Task of IEnumerable. This method uses a dbcontext class from entityframework to get the data. (i'm using MVVM).
This should be pretty straightforward but I'm getting the NullReferenceException. I wonder if it has anything to do with the way I'm using INotifyPropertyChanged.
Here's some of the code:
public class ExploradorFaturasViewModel : BindableBase
{
(...)
private ObservableCollection<Invoice> _invoices;
public ObservableCollection<Invoice> Invoices
{
get { return _invoices; }
set { SetProperty(ref _invoices, value); }
}
(...)
}
public class BindableBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected virtual void SetProperty<T>(ref T member, T val, [CallerMemberName] string propertyName = null)
{
if (object.Equals(member, val)) return;
member = val;
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Could you help me? Do you need more info or is this enough?