MVVM binding to Model or ViewModel?

 ̄綄美尐妖づ 提交于 2019-12-24 17:46:03

问题


I've been reading Microsoft's Prism Documentation and it has a lengthy discussion of the MVVM framework. Both the section discussing the Model and the one discussing the ViewModel talk about the View binding to the properties declared in each. Is this correct? Everything I read up until this made it seem like the ViewModel was the intended binding source, and the Model was more of the business logic. Any clarification would be appreciated.


回答1:


Almost all of the time you will be binding to ViewModels, which will wrap Models and add convenience functionality that has to do with your UI (and which would hardly belong to the Models directly). Sometimes not much convenience is required and you might end up binding to Models directly (although personally I choose to never do this).

The documentation is indeed a bit unclear on this as you mention, but in a nutshell your grasp of the situation is spot on.



来源:https://stackoverflow.com/questions/11786820/mvvm-binding-to-model-or-viewmodel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!