Cutting edge MVVMLight 1: MVVMLight introduction and use in projects, cutting edge mvvmlight

Source: Internet
Author: User

Cutting edge MVVMLight 1: MVVMLight introduction and use in projects, cutting edge mvvmlight
1. Introduction to MVVM and MVVMLightMVVM is short for Model-View-ViewModel. Similar to the popular MVC and MVP design patterns, the main purpose is to separate the coupling between views and models. It is an extremely good design Model, but not framework-level stuff, by the MVP (Model-View-Presenter) A new architecture that evolved from the application modes combined with WPF. Based on the original MVP framework and the new features of WPF are combined to cope with the increasingly complex needs of PC-side development. Structure: Compared to the method used to write the logic structure in Code Behind, MVVM almost completely decouples the relationship between views and logical businesses and processes UI attributes and event drivers through data binding and commands. Similarly, attribute changes caused by the View interaction business logic processing of ViewModel will also be notified to the View front-end, so that the View front-end can be updated in real time. Model stores data models, data logic, and business logic. In fact, I personally think that the layer of data and business interaction should be independent. The Model is completely an entity Model, which is clearer. This type of Bidirectional binding is excellent. Changes to views are automatically reflected on ViewModel, and vice versa. Currently, AngularJS is the front-end framework of JS. The MVVM mode is the same as the MVC mode. It mainly aims to separate views and models.1. Low coupling:Views can be changed and modified independently of the Model. A ViewModel can be bound to different views. The Model can remain unchanged when the View changes, when the Model changes, the View can also remain unchanged.2. reusability:Some View logic can be placed in a ViewModel, allowing many views to reuse this View logic.3. Independent Development:Developers can focus on business logic and data development (ViewModel). Designers can focus on page design. Using Expression Blend can easily design the interface and generate xml code.4. testable:The interface has always been difficult to test, but now the test can be written for ViewModel. If you want to learn more about MVVM, read this article. If you are currently developing Microsoft's WPF, Windows Phone, Windows 8, and SilverLight-related projects, it is necessary for me to understand the MVVM Light framework first. It is lightweight (relative to Prism), focused (only responsible for the implementation of MVVM architecture mode, no other redundant components), efficient (easy to use, time-saving and force-reduction ), it can help you better develop your applications. Author of MVVMLight: Laurent Bugnion is a Microsoft MVP. This is the official website of MVVMLight: Workshop. Interestingly, the MVVMLight product Logo is a feather, which implies the advantages we mentioned above: lightweight, professional, and efficient. I don't know if the author means this.2. How to Use MVMLight in your WPF ApplicationYou can download the MVVMLight Toolkit from the official website. After installation, the MvvmLight Project template is displayed in the VS template. You can use this project template to create a project. It will contain the default ViewModelLocator and MainViewModel. MainViewModel is the ViewModel of your Main view, and ViewModelLocator is a global ViewModel loading register. This article will be detailed in the second article. Another method is to install it on NuGet, which is undoubtedly the most convenient. Search for MVVM Light in the NuGet toolbox. You can see two projects: MVVM Light and MVVM Light libraries only. The current version is 5.3, which indicates that the MVVM Light update speed is still quite fast. There is also the ALAPHA version V5.4 in Prerelease. The difference between the two projects in Nuget is that in addition to necessary GalaSoft components, MVVM Light also adds related hierarchical file directories to form a simple MVVMLight molding framework. It will help you generate the ViewModel folder, which contains the MainViewModel and ViewModelLocator files. Now, the basic construction of a MVVMLight-based WPF project framework is complete. The following is a detailed description of the framework structure. Indicate the source for reprinting. Thank you.

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.