MVVM a new architecture framework

Source: Internet
Author: User
Tags silverlight

MVVM is shorthand for Model-view-viewmodel. Microsoft's WPF brings new technical experiences, such as Silverlight, audio, video, 3D, animation ..., which leads to a more detailed and customizable software UI layer. At the same time, at the technical level, WPF brings new features such as binding, Dependency property, Routed Events, Command, DataTemplate, ControlTemplate, and more. The origin of the MVVM (Model-view-viewmodel) framework is a new architectural framework that evolves when the MVP (Model-view-presenter) pattern is applied in conjunction with WPF. It is based on the original MVP framework and incorporates the new features of WPF to address the increasingly complex needs of our customers.
Foreign names
Model-view-viewmodel
Hereinafter
MVVM
For example
Silverlight, Audio
Membership
Microsoft
MVVM Benefits
Low coupling reusability
Directory
    1. 1 Example parsing
    2. 2 Design Patterns
    3. 3 MVVM Benefits
    4. 4 MVVM Control
MVVM Instance parsingEditing WPF's data binding with the presentation model is a great way to enable developers toMVVM function DiagramView and logic are separated, but this data binding technique is very simple and practical, and is unique to WPF, so we call it Model-view-viewmodel (MVVM). This model is similar to the classic MVP (Model-view-presenter) model, except that you need a model that is tailored to the View, which is viewmodel. ViewModel contains all UI-specific interfaces and properties, and is bound by a ViewModel view, and can be loosely coupled, so you need to write the code in the ViewModel direct update view. The data-binding system also supports the validation of input that provides a standardized way of transmitting validation errors to views. In the view section, typically an ASPX page. In previous design patterns, because there was no clear delineation of responsibilities, the UI layer often became the universal proxy for the logical layer, which actually belonged to the other layers of the application. The M in the MVP and the M in MVC are a model that encapsulates the computational relationships of core data, logic, and functions, while V is a view (form), p is a form that encapsulates all the actions in the forms, responds to the user's input and output, events, and so on, as in MVC, except that MVC is a system-level architecture. And MVP is used on a particular page, that is, MVP flexibility is far greater than MVC, the implementation is very simple. We then parse this interface layer from iview, which can help us decouple the various UI from the logical layer, and we can go from the UI layer to the automated test (unit/automatic test) and provide the portal, which can previously be form/by Winform/web The UI written by MFC is communicated with the iview layer through event Windows messages. The best way for WPF to communicate with the iview layer is to use binding, of course, to use events, and presenter layer to implement iview, the polymorphic mechanism ensures that the runtime UI layer displays the appropriate data. For example, in a program, you might see that the source of the binding is a variable of type interface, in fact, the object referenced by this interface variable is the real data source. MVC pattern Everyone is already very familiar with, here I do not repeat, these patterns are in turn evolved to form MVC->MVP->MVVM. There is a good saying: When the object is in the relay, where the interface is the most likely to be torn down. Therefore, iview as a layer of the public View Interface constraint (contract), the view can convey the decoupling of a layer of meaning.MVVM Design PatternEditors have improved the MVP design pattern because of the advent of WPF technology, and the MVVM pattern is using a data-binding infrastructure. They make it easy to build the necessary elements of the UI. You can refer to the Composite application Guidance for WPF view binding to ViewModel, and then execute some commands to request an action from it. In turn, ViewModel communicates with the model, telling it to update to respond to the UI. This makes it very easy to build the UI for your app. The easier it is to paste an interface into an application, the easier it is for the designer to use blend to create a nice interface. At the same time, as the UI and functionality become more and more loosely coupled, the testability of functionality becomes stronger. In MVP mode, designers add a layer of interface between the UI layer and the logical layer in order for the UI layer to detach from the logical layer. Both the UI developer and the data developer have to respect the contract and design and develop it according to it. This makes it possible to use the same set of data logic in an ideal state, whether it be a Web UI or a window UI. Draw on the MVP's iview layer and develop the habit. The View model sounds much more relevant than presenter, putting things related to events and commands in MVC's ' C ' or MVVM's ' VMS '.MVVMMVVM AdvantagesThe main purpose of the editing of the MVVM pattern and the MVC pattern is to separate views and models, with several advantages 1. Low coupling。 Views can be independent of model changes and modifications, a viewmodel can be bound to different "view", when the view changes the model can be unchanged, when the model changes when the view can be unchanged. 2. reusability。 You can put some view logic in a viewmodel and let many views reuse this view logic. 3. Independent development。 Developers can focus on business logic and Data Development (ViewModel), designers can focus on page design, and using Expression Blend makes it easy to design interfaces and generate XAML code. 4. Can be tested。 The interface is always more difficult to test, and now the test can be written for ViewModel.MVVMMVVM ControlsEdit using MVVM to develop user controls[1]。 Because user controls do not involve the persistence of data in most cases, using the MVVM pattern for customization if M is purely understood as Domainmodel Control DevelopmentYou can actually omit M and become a VVM.

MVVM a new architecture framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.