In ObservableCollection how can i check CollectionChanged event is null or not,
This statement throws syntax error
if (studentList.CollectionChanged == null)
ErrorMessage:
The event ‘System.Collections.ObjectModel.ObservableCollection.CollectionChanged’ can only appear on the left hand side of += or -=
Sample Code:
public class School
{
public School()
{
studentList = new ObservableCollection<Student>();
//only when studentList.CollectionChanged is empty i want
// to execute the below statement
studentList.CollectionChanged += Collection_CollectionChanged;
}
public ObservableCollection<Student> studentList { get; set; }
}
Events aren’t delegate instances.
Try this: