You can define a base view model and inherit it from INotifyPropertyChanged
public abstract class BaseViewModel : INotifyPropertyChanged { protected bool ChangeAndNotify<T>(ref T property, T value, [CallerMemberName] string propertyName = "") { if (!EqualityComparer<T>.Default.Equals(property, value)) { property = value; NotifyPropertyChanged(propertyName); return true; } return false; } protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public event PropertyChangedEventHandler PropertyChanged; }
then in your view model (JM example) will inherit from BaseViewModel and can create an ObservableCollection<YOURLISTCLASS> List
Also your fields in ViewModel (JM example) should be implemented as follows:
public const string FirstNamePropertyName = "FirstName"; private string firstName = string.Empty; public string FirstName { get { return firstName; } set { this.ChangeAndNotify(ref this.firstName, value, FirstNamePropertyName); } }
Hope this helps.
SoftSan
source share