I have this ViewModel:
public class CombustiblesViewModel
{
public List<CombustiblesWCFModel> Combustibles{ get; set; }
public CombustiblesViewModel()
{
Combustibles = _svc.Combustibles_List(sTicket);
}
}
Combustibles_List Returns a List From a WCF Service. What I need is to Track changes on Each CombustiblesWCFModel Object. So I Extend my Model with this code:
public CombustiblesWCFModel()
{
this.PropertyChanged += ChangedRow;
}
private void ChangedRow(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "HasChanges") return;
CombustiblesWCFModel p = (CombustiblesWCFModel)sender;
// Should Rise HasChanges Property on model, but it doesn't work
p.HasChanges = true;
}
private bool _haschanges;
public bool HasChanges
{
get
{
return _haschanges;
}
set
{
_haschanges = value;
this.RaisePropertyChanged("HasChanges");
}
}
}
My problem is that HasChanges is Always false. I believe that PropertyChanged event is overrited when the model is returned from WCF Service.
Question
So How can I detect Model changes on each object of the viewmodel collection?