什么使MVVM独特的适合WPF? [英] What makes MVVM uniquely suited to WPF?

查看:118
本文介绍了什么使MVVM独特的适合WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Model-View-ViewModel 非常受WPF和Silverlight的。我一直在为我最近的项目使用这个项目,而且是一个非常大的粉丝。



我明白这是 MVP 。但是,我正在想知道WPF(和Silverlight)的哪些独特特性允许MVVM工作,并且阻止(或至少使困难)这种模式使用其他框架或技术。


$ b $我知道MVVM对WPF中强大的数据绑定技术有很强的依赖性。这是许多文章和博客似乎都提到的一个功能,因为它是WPF的关键,它提供了View View与ViewModel强大分离的手段。但是,数据绑定存在于其他UI框架中的许多表单中。甚至还有一些项目,如桁架,它可以在.NET中为POCO提供WPF风格的数据绑定。



除了数据绑定之外,什么功能使WPF和Silverlight独特地适用于Model-View-ViewModel?

解决方案

DataBinding,命令,控件模板和XAML。



如果没有这些,MVVM会变得更难,如果不是不可能的话。以ASP.net为例,它具有ASPX部分(为了示例而言相当于XAML),它具有数据绑定,但没有命令或控件模板,因此MVVM是不可能的。在WinForms中,我们有数据绑定,几乎是这样,所以也不可能。


The Model-View-ViewModel is very popular with WPF and Silverlight. I've been using this for my most recent projects, and am a very large fan.

I understand that it's a refinement of MVP. However, I am wondering exactly what unique characteristics of WPF (and Silverlight) allow MVVM to work, and prevent (or at least make difficult) this pattern from working using other frameworks or technologies.

I know MVVM has a strong dependency on the powerful data binding technology within WPF. This is the one feature which many articles and blogs seem to mention as being the key to WPF providing the means of the strong separation of View from ViewModel. However, data binding exists in many forms in other UI frameworks. There are even projects like Truss that provide WPF-style databinding to POCO in .NET.

What features, other than data binding, make WPF and Silverlight uniquely suited to Model-View-ViewModel?

解决方案

DataBinding, commands, control templates and XAML.

Without one of these, MVVM would be a lot harder, if not impossible. Take ASP.net for instance, it has the ASPX part (which for the sake of the example is equivalent to XAML), it has data binding, but it doesn't have commands or control templates, so MVVM is not possible there. In WinForms, we have databinding, and that's pretty much it, so not possible either.

这篇关于什么使MVVM独特的适合WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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