我为简单的MVVM模式实现了INotifyPropertyChanged
。我的模型中有一个类,未在视图模型中实现INotifyPropertyChanged和ObservableCollection<class>
。
当不同的column(cell)值更改时,我需要运行不同的方法。如果不是绝对必要,我真的不想对模型实现INotifyPropertyChanged
。
我尝试了这个ObservableCollection not noticing when Item in it changes (even with INotifyPropertyChanged)解决方案,但无法解决。
//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; }
}