标签:
ps:http://waf.codeplex.com/wikipage?title=Model-View-ViewModel%20Pattern&referringTitle=Documentation
Model-View-ViewModel Pattern
Common abbreviations: M-V-VM or MVVM
Separating user interface code from everything else is a key principle in well-engineered software.
在软件设计里 分隔 一个关键的原则
But it’s not always easy to follow and it leads to more abstraction in an application that is hard to understand.
但是 应用里 越多的抽象 很难理解
Quite a lot design patterns try to target this scenario: MVC, MVP, Supervising Controller, Passive View, PresentationModel, Model-View-ViewModel, etc.
很多设计模式 努力去实现 这些场景:MVC,MVP,管理控制器,被动视图,表示层模型,
The reason for this variety of patterns is that this problem domain is too big to be solved by one generic solution.
各种各样的模式的原因 是 通用型解决方案去解决问题太 困难 。
However, each UI Framework has its own unique characteristics and so they work better with some patterns than with others.
然而 每个 UI框架 有自己唯一的特征 ,所以 有些模式会比其他的更合适。
The WPF Application Framework (WAF) provides support for the Model-View-ViewModel Pattern because this one works best with Windows Presentation Foundation (WPF) applications.
WAF 支持 MVVM 模式 因为 它能在 微软推出的用户界面框架 表现很不错。
This pattern is also known as PresentationModel pattern.
这个模式被认为是 表示模型。
Definition
Represent the state and behavior of the presentation independently of the GUI controls used in the interface.
表述 状态 和 行为 表达 与 GUI 控件 无关的 接口
A popular description of this design pattern is done by Martin Fowler.
Martin Fowler 对 一个 流行 设计模式 的描述
In his article the pattern is called PresentationModel but it is the same pattern.
但是 相同的设计模式 在他的文章里 这个设计模式被叫做 表示 模型
You can read his article online on his website.
你可以在他的 网站 阅读他的文章。
The following chapters describe our specific .NET implementation of this design pattern.
我们特地用.net实现了文章里面描述的设计模式。
Structure
The following UML class diagram shows the collaborating classes of this design pattern in a logical layered architecture.
在 逻辑层 下面UML类图展示了 设计模式里各个类的协作。
Participants 参与者
The types participating in this pattern are:
View contains the specific GUI controls and defines the appearance of the user interface.
IView declares the interface of the View.
在模式里的参数类型有:
视图包含 特别的GUI控件 和 出现的 用户界面。
The ViewModel can communicate over this interface with the View.
ViewModel 通过 接口和 View 沟通。
Related pattern: Separated Interface (PoEA).
有关模式: 分开的接口
ViewModel represents the state and behavior of the presentation.
ViewModel 代表 展示层的 状态和行为
Model can be a business object from the domain layer or a service which provides the necessary data.
Model 是 业务对象 的领域层 或者 提供必要数据的服务层。
Controller is responsible for the workflow of the application. Furthermore, it mediates between the ViewModels.
控制器 对工作流应用程序负责。 此外, 他介于 ViewModels。
So it promotes loose coupling by keeping the ViewModels from referring to each other explicitly.
它可促进 涉及其他的明确的 保持 ViewModels 松散耦合
Related patterns: Application Controller (PoEA), Mediator (GoF)
相关模式: 应用控制器 ,中介者模式
Remarks 备注
The introduction of the interface IView is a variation of the Model-View-ViewModel pattern.
IView 是 Model-View-ViewModel 模式的变种。
It allows the ViewModel to call properties and methods on the View.
在view里 允许ViewModel调用 View里的属性和方法。
The Controller class is not part of this design pattern.
控制器不是设计模式的一部分。
The controller is supported by the WPF Application Framework (WAF) and so this article shows how the controller works together with the M-V-VM pattern.
控制器支持 WAF,所以这篇文章展示 控制器 怎么样和 MVVM模式一起工作。
每天翻译一点点: WPF Application Framework (WAF)
标签:
原文地址:http://www.cnblogs.com/ganmk--jy/p/5539507.html