在WPF中实现MVC的验证功能 [英] Implement validation feature of MVC in WPF

查看:83
本文介绍了在WPF中实现MVC的验证功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC中使用数据注释非常简单。我想知道如何在WPF中做同样的事情。任何想法。

我搜索并看到了各种接口实现INotifyDataErrorInfo,INotifyPropertyChanged等。是否有任何方法限制编码为wpf设计器和形式代码背后?????

Using Data annotation in MVC is so easy. I wonder how i could do the same in WPF. Any ideas.
I Searched and saw all sorts of interface implementation INotifyDataErrorInfo, INotifyPropertyChanged etc. Is there any way that restricts coding to wpf designer and form code behind?????

推荐答案

请参阅我对问题的评论,在那里我解释为什么难以回答你的问题。这不是一个富有成效的问题,因为你不会问任何确定的事情,你只是希望WPF与ASP.NET MVC类似。这是不合理的。 WPF有你自己需要理解的方式。



至于你提到的接口,请看这里:

http://bit.ly/1p6M2FU [ ^ ],

http://bit.ly/1p6MfJj [ ^ ]。



当你可以看出,你对这些界面的抱怨是毫无根据的。但是我不想进一步详细说明,因为你没有用WPF制定任何问题。



现在,注意WPF它更多典型地实现MVVM而不是MVC。 MVVM的开发考虑了WPF:

http://en.wikipedia.org/wiki/MVVM [ ^ ]。



但是,没有什么可以阻止任何人使用MVC和WPF。只有你应该确保你对MVC一词的理解不够深入。首先,这是架构(不仅仅是ASP.NET上的一些框架):

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller [ ^ ]。



-SA
Please see my comment to the question where I explain why it would be difficult to answer your question. This is not a productive question, because you don't ask about anything certain, you just "want" WPF to be similar to ASP.NET MVC. This is not reasonable. WPF has its own ways you just need to understand.

As to the interfaces you mentioned, just look here:
http://bit.ly/1p6M2FU[^],
http://bit.ly/1p6MfJj[^].

As you can see, your complain about these interface was baseless. But I don't want to go in for further detail, because you did not formulate any certain problem with WPF.

Now, pay attention that for WPF it is more typical to implement MVVM rather then MVC. MVVM was developed having WPF in mind:
http://en.wikipedia.org/wiki/MVVM[^].

However, nothing prevents anyone from using MVC with WPF. Only you should make sure that you don't have too narrow understanding of the term "MVC". First of, all, this is the architecture (not just some framework on top of ASP.NET):
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller[^].

—SA


这篇关于在WPF中实现MVC的验证功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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