I need to identify if a list is updated (item added/removed). I need to use System.Collections.Generic.List<T>
, I cannot use ObservableCollection
for this (and subscribe to it's CollectionChanged
event).
Here is what I have tried so far:
I am using Fody.PropertyChanged
instead of implementing INotifyPropertyChangedEvent
- Fody Property Changed on GitHub
[AlsoNotifyFor("ListCounter")]
public List<MyClass> MyProperty
{get;set;}
public int ListCounter {get {return MyProperty.Count;}}
//This method will be invoked when ListCounter value is changed
private void OnListCounterChanged()
{
//Some opertaion here
}
Is there any better approach. Please let me know if I am doing something wrong, so that I can improve.
You can use extension methods:
Extension method itself.