I have a wpf app, MVVM-style, with a (Telerik Rad)Gridview. I want to have an event every time user updates a cell.
The GridView is bound to the MyRowModel
public class MyRowModel : INotifyPropertyChanged
{
//...
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
I want to handle them in my View Model, I bind them like this
var rows = MyRows.ForEach(p=> p.PropertyChanged += MyPropertyChangedHandler);
This works, but do I need to unbind the events somewhere? The user can move back from this view, and select another set of rows. Moreover I will get updated rows from servier every time there is a cell change.
2, bonus question) Are these (in my case MyRowModel ) View Models or Models?