Reading up on SO answers regarding what WPF, MMVM model classes contains, it is clear, that in larger applications the general recommendation is to avoid NotifyPropertyChanged
and INotifyCollectionChanged
outside the presentation layer.
But how would I practically implement this? Say I have a Model.Student
class and a StudentService
class that returns IList<Student>>
from a service layer. My view model would look something like this:
public class StudentViewModel : ViewModelBase
{
private readonly ObservableCollection<Student> students;
public StudentViewModel(IStudentService service)
{
students = new ObservableCollection<Student>(service.GetAllStudents());
}
}
How would I DataBind properties from a single student? Say one of the student names is changed and should be reflected in the View. Would I have to translate the Student classes into some other class that implements INotifyPropertyChanged
(and INotifyCollectionChanged
if there are collection properties)?
How do you recommend dealing with this if you want to keep the (business) model free from presentation specific details?