MVP-VM(模型视图演示者-视图模型) [英] MVP-VM (Model View Presenter-View Model)

查看:84
本文介绍了MVP-VM(模型视图演示者-视图模型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理C#winForm项目,并且正在应用MVP-VM ...我不了解将UI小部件绑定到"ViewModel"的好处,实际上这只是一个我的模型的反映.在我看来,我只是不必要地添加了另一层抽象.为什么不直接将我的Model(businessObj)传递给我的View(Form)并将其绑定到适当的UI小部件,而不是绑定ViewModel?

I''m working a C# winForm project and I''m applying MVP-VM...I''m not understanding the benefit(s) of binding my UI widgets to my "ViewModel" which is actually just a reflection of my Model. Seems to me like I''m just adding another layer of abstraction unnecessarily. Why not just pass my Model(businessObj) to my View(Form) and bind it to the appropriate UI widget(s) instead of binding the ViewModel?

推荐答案

通常您的视图模型将包含与特定任务有关的所有数据,这些数据将跨越不同Model对象的边界.我发现一直使用MVC,我有了我的模型类,再加上这一页中需要的一些信息,以了解我如何处理这些数据.
Often your view model will contain all the data pertaining to a specific task, which will cross boundaries of different Model objects. I find that with MVC all the time, I have my model class, plus a few bits of info I need in just this one page to know how I am dealing with that data.


这篇关于MVP-VM(模型视图演示者-视图模型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆