I have a class which contains a list :
public class a
{
private List<MyType> _Children;
public Children
{
get {return(_Children);}
set {_Children = value ;}
}
}
I want to create an event and fire that event whenever my list (_Children here) is changed for example an item is added to it or removed from it or it's cleared .
thanks
Change your list to an ObservableCollection<T>
. It implements INotifyCollectionChanged , so you can subscribe to change events on it.
Another option is to use BindingList<T>
, if you need full list semantics.
Or if you want to control the Add and remove methods and raise event, check Collection<T>
out.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.