Where / When / How to BindingList <T> convert / attach theChanged property to the ListChanged event
I have a hierarchy of objects that all implement INotifyPropertyChanged. I also have my own list, which comes from a BindingList.
I understand that when I add an object that impelements INotifyPropertyChanged to the list, somehow the PropertyChanged event is automatically transferred / converted to the ListChanged event.
However, after I set my list as the data source of my DataGridView, when I change the value in the grid, the ListChanged event does not fire ... When I enter the code, it turns out that the PropertyChanged () event does not fire because it is null that I mean that it does not get wired / converted to the BindingList ListChanged event, for example its supposed ...
For example:
public class Foo : INotifyPropertyChanged
{
//Properties...
private string _bar = string.Empty;
public string Bar
{
get { return this._bar; }
set
{
if (this._bar != value)
{
this._bar = value;
this.NotifyPropertyChanged("Bar");
}
}
}
//Constructor(s)...
public Foo(object seed)
{
this._bar = (string)object;
}
//PropertyChanged event handling...
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(String info)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
And here is my own list class ...
public class FooBarList : BindingList<Foo>
{
public FooBarList(object[] seed)
{
for (int i = 0; i < seed.Length; i++)
{
this.Items.Add(new Foo(this._seed[i]));
}
}
}
Any ideas or suggestions?
Thanks!
Josh