Home > Web Front-end > Front-end Q&A > What are the mvvm frameworks?

What are the mvvm frameworks?

青灯夜游
Release: 2020-11-17 15:28:55
Original
12617 people have browsed it

The mvvm framework includes: 1. MVVMLight framework, a lightweight framework that implements the MVVM pattern; 2. Prism framework; 3. Caliburn framework, an open source framework for MVVM classes; 4. MVVM Helpers framework; 5. Cinch framework; 6. MVVM Foundation framework

What are the mvvm frameworks?

##The framework to implement MVVM

1. The most powerful and versatile composition framework - Prism

Download address: http://compositewpf.codeplex.com/

Developer: Microsoft patterns & practices team

Whether Silverlight is supported: Yes

Learning materials: Composite Application Guidance for WPF and Silverlight - May 2010.chm and Quickstarts and StockTraderRI, etc.

Source code screenshots are as follows:

What are the mvvm frameworks?##Prism——previously called Composite Application Guidance for WPF and Silverlight, it is a complex enterprise-level application based on WPF/Silverlight Mainstream application framework. There are several important concepts in Prism:

1. BootStrapper: The application entry point, inherits Prism's UnityContainer or the MefUnityContainer provided by MEF, and provides a container for the system.

2, Shell: It is a shell that layouts pages through UI elements and Regions. It is the top-level window of the application, and the displayed content is generally filled by View. The Shell itself does not know what content it contains, so the functions are specifically provided by each Module.

3, View: It is equivalent to View in MVP mode and MVVM mode. It can be injected into Region through IRegionManager.

4, Module: A large project can be split into parts. Each Module contains View, data, and model, and is mainly used to implement complex business operations.

5, IModuleManager: mainly used to manage module loading and can achieve dynamic loading.

6, IEventAggregator: event processing interface, implementing subscription and publishing modes, which is also the general practice of MVVM framework.

Prism is a relatively large combination framework. It has become more powerful after the introduction of MEF and functional adjustments in 4.0. Now it can be said to be the unity of the combination framework and application framework, and it is the strength of the Microsoft team, so I chose It's worth guaranteeing.


2. The most powerful and versatile application framework - Caliburn

Download address: http://caliburn.codeplex.com/

Developer: Rob Eisenberg

Does Silverlight support: Yes

Learning materials: I mainly refer to project examples, source code, unit test cases, and some foreign blogs and communities.

Source code screenshots are as follows:

What are the mvvm frameworks?There are several important concepts in Caliburn:

1, Commands based on Actions There are many features, including multiple parameters, filter operations, and asynchronous calls.

2. The life cycle events of forms and controls are also handled relatively well (including activation, deactivation, shutdown, etc.).

3. The testability of both the entire framework and applications based on this framework is relatively good.

4, provides many common functions, which are more useful in projects.

5, in addition to supporting the MVVM mode, it also supports the MVP mode and other variant modes.

6, powerful dependency injection framework and AOP framework, you can flexibly choose one of them here.

Caliburn is a very powerful MVVM application framework that provides flexible and diverse implementations of many functions. Whether it is project use or code research, I feel that it has benefited a lot.

3. Lightweight and applicable MVVMLight

MVVMLight is a lightweight framework that implements the MVVM pattern (relative to Prism), which can better help us Develop WPF, Windows Phone, Windows 8, SilverLight related projects.

Laurent Bugnion, the author of MVVMLight, is a Microsoft MVP. The author open sourced the code to Codeplex: http://mvvmlight.codeplex.com/.

MVVMLight’s official website: http://www.mvvmlight.net/, which has detailed introduction and video documents. If you are interested, you can learn more.

Download address: http://mvvmlight.codeplex.com/

Developer: Laurent Bugnion

Support Silverlight: Yes

Learning materials: In addition to online documentation, I mainly refer to project examples, source code, unit test cases, and some foreign blogs and communities. In addition, these three articles are very good. I developed a relatively complete Silverlight enterprise project using MVVMLight

    Part 1 - Introduction, Installation, and General Application Design Topics
  • Part 2 - MVVM Light Topics
  • Part 3 - Custom Authentication, Reset Password and User Maintenance
  • The source code screenshot is as follows:

What are the mvvm frameworks?There are several important concepts in MVVMLight:

1, RelayCommand: By encapsulating Command, the MVVM mode is easier to use on WPF and Silverlight. You only need to define each RelayCommand in the ViewModel, and then use the Command to bind the RelayCommand defined in the ViewModel in the View to achieve the same effects as WinForm and ASP.NET events, but here the UI and logic are removed strong coupling.

2, Messager: The Messager in MVVMLight plays a relatively large role. As mentioned earlier, the MVVM mode removes the strong references of ViewModel and View, so how do they interact? It is used to allow ViewModel and View to communicate. Generally, we will define a static AppMessages class as a general communication class. The principle is the publish-subscribe model.

3, EventToCommand: This is similar to the concept of additional behavior, which was introduced in MVVM Light Toolkit V3.

4, ICleanup interface: When displaying a View, you need to first call the Cleanup method to clear the data. This is also some necessary operations due to the coupling isolation of ViewModel and View.

MVVMLight is a very easy-to-use MVVM framework that provides templates and intelligent sensing for VS and Blend. It feels really lightweight and efficient when used in combination with MEF, and it provides support for WPF and Silverlight, especially Silverlight support, so generally choose the lightweight Silverlight MVVM mode, which is more promising.

4. Full-featured and easy-to-use MVVM Helpers

Download address: http://mvvmhelpers.codeplex.com/

Developer: Mark Smith

Whether to support Silverlight: No

Learning materials: http://www.julmar.com/blog/mark/ and the provided examples, source code and test cases.

The source code screenshot is as follows:

What are the mvvm frameworks?

##MVVM Helpers is also called JulMar MVVM Helpers Behaviors, which has several important concepts:

1 , provides the basic functions of the MVVM model, including the isolation between ViewModel, View and Model, and also provides some common functions.

2. The creation of ViewModel is injected in the form of tags, and MEF can also be introduced now.

3. IOC/DI support, attributes have verification mechanisms, and Wait Cursor support can be released in time after the viewmodel is used, thus avoiding memory leaks.

4. Provides support for commonly used Attached Behaviors.

5. The introduction of message mechanism to avoid coupling caused by strong references.

MVVM Helpers is a very applicable MVVM framework, especially it provides the common MVVM functions MEF Attached Behaviors, so the problems in the project can basically be solved.

5, powerful and lightweight Cinch

Download address: http://cinch.codeplex.com/

Developer: Sacha Barber

Whether Silverlight is supported: No

Learning materials: http://sachabarber.net/ and provided examples, source code and test cases.

The screenshot of the source code is as follows:

What are the mvvm frameworks?

If you study the code carefully, you will find that it has a lot of similar code to the MVVM Helpers mentioned above, and they are probably related to each other. I made a reference :-D. There are several important concepts in Cinch:

1. This framework has already implemented strong reference isolation between ViewModel and View before MEF appeared. It has neither general IOC configuration nor IView. It is used for transfer, and the life cycle events of forms and controls are also handled relatively well, so it is very good in this regard.

2, provides support for commonly used Attached Behaviors, and also provides some common MVVM functions.

3, DI/IOC is implemented using Unity and multi-threaded to avoid unpredictable errors in the system.

4. When the viewmodel is used, it can be released in time to avoid memory leaks. The verification mechanism is added and common navigation is implemented.

5, the introduction of message mechanism to avoid coupling caused by strong references.

Cinch is a very powerful framework, especially because it focuses on the construction of the entire application, so it is also more popular.

6. MVVMFoundation with simple functions and easy expansion

Download address: http://mvvmfoundation.codeplex.com/

Developer: Josh Smith

Whether it supports Silverlight: No

Learning materials: http://joshsmithonwpf.wordpress.com/ and the provided examples, source code and test cases.

Source code screenshots are as follows:

What are the mvvm frameworks?

There are several important concepts in MVVM Foundation:

1, Messenger: This is mainly used in various Communication between different ViewModels (such as interrelated ViewModels, master-slave ViewModels, etc.), of course, can also be extended to communication between ViewModel and View.

2, ObservableObject: This is equivalent to the concept of ViewModelBase. Each ViewModel inherits from this class and is released immediately after the call is completed to prevent memory leaks.

3, PropertyObserver: Mainly encapsulates INotifyPropertyChanged.PropertyChanged, so that encapsulation can simplify the code and prevent memory leaks caused by improper operations.

4, RelayCommand interface: encapsulates the command statement, including execution execution logic, optional can-execute logic, etc. Externally, you only need to instantiate and Binding to use it easily.

MVVMFoundation is a very simple MVVM framework. If you find it difficult to study the source code, you can start with this framework first. The code is simple and refined.

For more programming-related knowledge, please visit: Programming Learning Website! !

The above is the detailed content of What are the mvvm frameworks?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template