MVVM in WPF - How to alert ViewModel of changes in Model… or should I?

前端 未结 11 670
离开以前
离开以前 2020-11-27 09:51

I am going through some MVVM articles, primarily this and this.

My specific question is: How do I communicate Model changes from the Model to the ViewModel?<

11条回答
  •  自闭症患者
    2020-11-27 10:24

    There's nothing wrong to implement INotifyPropertyChanged inside Model and listen to it inside ViewModel. In fact you can even dot into model's property right in XAML : {Binding Model.ModelProperty}

    As for dependent / calculated read-only properties, by far I haven't seen anything better and simpler than this: https://github.com/StephenCleary/CalculatedProperties. It's very simple but incredibly useful, it's really "Excel formulas for MVVM" - just works same way as Excel propagating changes to formula cells without extra effort from your side.

提交回复
热议问题