I need help implementing INotifyPropertyChanged in my own data structure class. This is for a class assignment, but implementing INotifyPropertyChanged is an addition that I am doing above and beyond what the rubric requires.
I have a class named 'BusinessRules' that uses a SortedDictionary to store objects of 'Employee' type. I have a DataGridView showing all of my employees, and I want to use my BusinessRules class object as the DataSource for my DataGridView. The BusinessRules container is required for the assignment. I have tried to implement INotifyPropertyChanged in this class, with no success.
The DataSource that I have working is a BindingList. Presently, I am using that BindingList as a 'sidecar' container and setting that as my DataSource. Every change that I make to my BusinessRules class object is mirrored to my BindingList class object. But this is obviously sloppy programming, and I want to do better.
I have tried to implement INotifyPropertyChanged in BusinessRules, but when I set my instantiated BusinessRules object as the DataSource, the DataGridView shows nothing. What I suspect the problem to be is with the NotifyPropertyChanged() method. I do not know what to pass to this, nor what to do with what is passed in. Most examples deal with changing a name, but I am more concerned when a new object is added to the SortedDictionary.
private void NotifyPropertyChanged( Employee emp )
{
PropertyChanged?.Invoke( this, new PropertyChangedEventArgs( emp.FirstName ) );
}
What do I need to change in order to get this working? Will you explain why my attempt is not working?
I am notoriously bad about forming my questions on StackOverflow. This is not intentional. Please, let me know what other information you require, and I will provide it as quickly as I can.