I have a public property called Items, It's a List. I want to tell when it's been altered. How can I do this?
For example, if Items.Add is called, I want to be able to then call UpdateInnerList.
How can I do this?
I have a public property called Items, It's a List. I want to tell when it's been altered. How can I do this?
For example, if Items.Add is called, I want to be able to then call UpdateInnerList.
How can I do this?
How about creating a List subclass and overriding the Add method?
void Main()
{
var x=new MySpecialList<string>();
x.Add("hello");
}
class MySpecialList<T>:List<T>
{
public new void Add(T item)
{
//special action here
Console.WriteLine("added "+item);
base.Add(item);
}
}
It supports a CollectionChanged event which should be what you need.