I implemented INotifyPropertyChanged
for a simple MVVM pattern. I have a class in model not implementing INotifyPropertyChanged and ObservableCollection<class>
in my viewmodel.
I need to run different methods when different column(cell) values changed. I don't really want to implement INotifyPropertyChanged
to the model if it is not absolutely necessary.
I tried this ObservableCollection not noticing when Item in it changes (even with INotifyPropertyChanged) solution but couldn't managed to work it out.
//ViewModel
public class LimitsViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
ObservableCollection<SingleLimit> _limitsclone= new ObservableCollection<SingleLimit>();
public ObservableCollection<SingleLimit> LimitClone
{
get { return _limitsclone; }
set
{
if (_limitsclone != value)
_limitsclone = value;
OnPropertyChanged();
}
}
}
//Model
public class SingleLimit
{
public string frstr{ get; set; }
public double X{ get; set; }
public double MaxP{ get; set; }
public double MaxM{ get; set; }
}