有关MVVM模式的一些基本问题 [英] Some Basical Questions About MVVM Pattern

查看:80
本文介绍了有关MVVM模式的一些基本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们
我已经研究了不错的MVVM模式,并打算在我的应用程序中使用它.
但是我发现有些晦涩的东西,我需要别人让它们对我清楚:

1-在RelayCommand类中使用Action有什么好处?
2-为什么在模型类而不是ViewModel类中应用验证?

等待您的宝贵答案,
的确感谢我亲爱的朋友.

Hi Guys
I''ve studying the nice MVVM pattern and going to use it in my application.
But I''ve found some obscurer thing which i need to somebody make them clear for me:

1-what is the benefit of using Action in RelayCommand Class?
2-Why the Validation Applied in the Model Class instead Of ViewModel Classes?

wait Your valuable answers,
Thanks indeed my dear Friends.

推荐答案

为什么将验证应用于模型类而不是ViewModel类?

这是处理数据的类.
这也是已实现INotifyProperty的类.因此在这里进行验证很有意义.

但是,也没有什么可以阻止您在视图模型中实现验证.

IMO,没有一条规则或另一条规则,只需选择一种自己喜欢的方式即可.
Why the Validation Applied in the Model Class instead Of ViewModel Classes?

This is the classes that handles data.
This is also the class that has INotifyProperty implemented. So it makes sense to have validations here.

However, there is nothing stopping you from implementing validations in the view model as well.

IMO, there is no one rule or the other, just choose a way you are comfortable with.


感谢abhinav,
那么使用ACTION怎么办?
thanks abhinav,
so whats about Using the ACTION?


这篇关于有关MVVM模式的一些基本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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