In a view model, I have a collection of items of type \"ClassA\" called \"MyCollection\". ClassA has a property named \"IsEnabled\".
class MyViewModel
{
Instead of using a List, try using an ObservableCollection. Also, modify your ClassA so that it implements INotifyPropertyChanged, particularly for the IsEnabled property. Finally, modify your MyViewModel class so it also implements INotifyPropertyChanged, especially for the MyCollection property.
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