In a view model, I have a collection of items of type \"ClassA\" called \"MyCollection\". ClassA has a property named \"IsEnabled\".
class MyViewModel
{
ClassA needs to implement INotifyPropertyChanged :
class ClassA : INotifyPropertyChanged
{
private bool _isEnabled;
public bool IsEnabled
{
get { return _isEnabled; }
set
{
if (value != _isEnabled)
{
_isEnabled = value;
OnPropertyChanged("IsEnabled");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
EDIT: and use an ObservableCollection like Scott said
EDIT2: made invoking PropertyChanged event shorter