I have one ObservableCollection in my ViewModel with INotifyPropertyChanged
, say A. Now I am going to loop through A to get some elements updated.
public ObservableCollection<ClassA> A
{
get
{
if (this.a== null)
{
this.a= new ObservableCollection<ClassA>();
}
return this.a;
}
set
{
this.a= value;
this.OnPropertyChanged("A");// implement PropertyChangedEvent
}
}
In the loop I update the values.
foreach (var item in MyViewModel.A)
{
if(condition)
MyViewModel.A.Type= "CASH";
else
MyViewModel.A.Type= "CHECK";
}
But I see the setter part is not reached. so the collection is not updated.