WPF Open Source Collection

Source: Internet
Author: User
Tags silverlight

1, what are the open source MVVM frameworks?

The basic concepts and knowledge of WPF are described earlier, and we understand that developing WPF applications can use out-of-the-box frameworks and patterns, most suitable for the now-hot MVVM pattern, so here we also list the existing open source frameworks for the MVVM pattern:

Figure 3

Above in addition to Wpftoolkit and MEF are some commonly used MVVM framework, with their own development of a total of eight, so they also took a loud name--MVVM eight frame! The Templars himself used only three frames in the actual project, before WPF used the MVVM Helpers, used MVVMLIGHT+MEF in the Silverlight project, and later used the framework that he developed, and other frameworks studied for a long time, But it's all about developing the MVVM framework for reference. Although the framework is numerous, but original aim, the general functions are as follows:

Relationships between 1,model, view, and ViewModel: How the View and ViewModel relate (IOC) and how to communicate (usually with a message), a weak association between ViewModel and Model (usually with an interface or simple injection).

2, the event-driven mode takes the form of command and attached behaviors in the MVVM pattern.

3, properties and ViewModel of notifypropertychanged processing.

4, provide complete unit testing, which is to ensure the stability and maintenance of the framework guarantee.

Maybe some friends will ask me why I have to study so many frameworks, in fact, the project only need to carefully study and practice one of them, the reason for studying them is mainly due to the need to develop the MVVM framework. Let's take a look at what MVVM's open-source frameworks are (specific to the time behind each frame, and a piece of paper is really tiring):

2, the most powerful and most versatile combo frame--prism

: 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 as well as QuickStarts and Stocktraderri.

The source code is as follows:

Figure 4

prism--, previously called composite Application Guidance for WPF and Silverlight, is a mainstream framework for building complex wpf/silverlight enterprise-class applications. There are several more important concepts in prism:

1,bootstrapper: An application pointcut that inherits the Mefunitycontainer provided by the Prism's UnityContainer or MEF, providing a container for the system.

2,shell: It is a shell, through UI elements and region layout pages. It is the top-level window of the application, and the content that is displayed is generally populated by view, and the shell itself does not know what it contains, so the function is provided specifically by each module.

3,view: It is equivalent to View in MVP mode, MVVM mode. Can be injected into the region via Iregionmanager.

4,module: A large project can be split, each Module contains view, data, model, mainly for the implementation of complex business operations.

5,imodulemanager: Mainly used for the management module load, can realize dynamic loading.

6,ieventaggregator: The event processing interface, which implements the subscription and release patterns, is also a general practice of the MVVM framework.

Prism is a large composite framework, the 4.0 introduction of MEF and functional adjustment has become more powerful, now can be said to be a combination of framework and application framework of the unity, but also the strength of the Microsoft team, so it is warranted to choose it.

3, the most powerful and most functional application framework--caliburn

: http://caliburn.codeplex.com/

Developer: Rob Eisenberg

Whether Silverlight is supported: Yes

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

The source code is as follows:

Figure 5

There are several more important concepts in Caliburn:

1, the commands on the actions basis are very versatile, including multiple parameters, filtering operations, and asynchronous calls.

2, the life cycle events for forms and controls are also handled better (including activation, deactivation, shutdown, and so on).

3, both the entire framework and the application based on this framework are better testability.

4, it provides a lot of common functions, which are useful in the project.

5, in addition to supporting the MVVM mode, also good support MVP mode and some other variants of the model.

6, a powerful dependency injection framework and an AOP framework, where one can be flexibly selected.

Caliburn is a very powerful MVVM application framework that offers flexible and versatile implementations for many functions, both for project use and for research code.

4, lightweight and applicable mvvmlight

: http://mvvmlight.codeplex.com/

Developer: Laurent bugnion

Whether Silverlight is supported: Yes

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

    • 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 is as follows:

Figure 6

There are several more important concepts in Mvvmlight:

1,relaycommand: The command is encapsulated to make the MVVM pattern easier on WPF and Silverlight. You only need to define the individual relaycommand in the ViewModel and then, in the view, bind the Relaycommand defined in ViewModel by command, and you can implement the WinForm, ASP, and so on. NET event, except that it relieves the strong coupling of the UI and logic.

The Messager role in 2,messager:mvvmlight is relatively large, and the previous MVVM pattern removes the strong references to ViewModel and view, so how do they interact? It's the way to make viewmodel and view communicate. In general, we will define a static Appmessages class as a common communication class, the principle is the Publish subscription mode.

3,eventtocommand: Here is a more similar concept of additional behavior, which is introduced in the MVVM light Toolkit V3.

4,icleanup interface: When displaying a view, you need to call the cleanup method to clear the data, which is also due to the ViewModel and view of the coupling isolation produced some necessary actions.

Mvvmlight is a very useful MVVM framework that provides templates and IntelliSense for VS and Blend. It is lightweight and efficient to use with MEF, and provides support for WPF and Silverlight, especially for Silverlight support, so it's generally a good choice for a lightweight Silverlight MVVM pattern.

5, full-featured and easy to use MVVM Helpers

: http://mvvmhelpers.codeplex.com/

Developer: Mark Smith

Whether Silverlight is supported: No

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

The source code is as follows:

Figure 7

MVVM Helpers is also called Julmar MVVM Helpers + behaviors, which has several more important concepts:

1 provides the basic functionality of the MVVM pattern, including ViewModel, view, and model isolation, as well as a number of common features.

The creation of 2,viewmodel is injected in the form of a label and can now be introduced to MEF.

3,ioc/di support, properties have authentication mechanism, WAIT cursor support, when the use of ViewModel can be released in time, so as to avoid memory leaks.

4, provides common attached behaviors support.

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

MVVM helpers is a very well-suited MVVM framework, especially for +mef+attached behaviors, which is commonly used in MVVM, so problems in the project can be solved basically.

6, powerful and lightweight cinch

: http://cinch.codeplex.com/

Developer: Sacha Barber

Whether Silverlight is supported: No

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

    1. A Walkthrough of Cinch, and its internals-part I
    2. A Walkthrough of Cinch, and its internals-part II
    3. How to develop ViewModels using Cinch
    4. How to the Unit test ViewModels using Cinch app, including how to test Background work threads which may run within C5>cinch ViewModels
    5. A Demo app using Cinch

The source code is as follows:

Figure 8

If you look at the code carefully, you'll find that it has a lot of similar code with the MVVM helpers above, and it's estimated to refer to each other:-D. There are several more important concepts in Cinch:

1, this framework has implemented a strong reference isolation between ViewModel and view without the advent of MEF, which does not have a general IOC configuration, does not have iview to do the relay, and the life cycle events of forms and controls are handled better, so this is very good.

2, it provides common attached behaviors support, and also provides some features that are commonly used in MVVM.

3,DI/IOC uses unity to implement multi-threaded implementations to avoid unpredictable errors in the system.

4, when the use of ViewModel can be released in a timely manner, so as to avoid memory leaks, the addition of authentication mechanisms, common navigation implementation.

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

Cinch is a very powerful framework, especially when it looks at the entire application building, so it's also a bit more popular.

7, simple and easy to expand mvvmfoundation

: http://mvvmfoundation.codeplex.com/

Developer: Josh Smith

Whether Silverlight is supported: No

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

The source code is as follows:

Figure 9

There are several more important concepts in mvvmfoundation:

1,messenger: This is mainly used for communication between various viewmodel (such as interrelated viewmodel, master-slave ViewModel, etc.), and of course, it can be expanded to communicate between ViewModel and view.

2,observableobject: This is equivalent to the concept of viewmodelbase, where each viewmodel inherits from the class and is released immediately after the call is complete to prevent memory leaks.

3,propertyobserver: The main thing is to encapsulate the inotifypropertychanged.propertychanged, so that the encapsulation can streamline the code while preventing the memory leaks caused by improper operation.

4,relaycommand interface: A declaration that encapsulates a command, including execution execution logic, optional can-execute logic, and so on. The external only needs to be instantiated and the binding is simple to use.

Mvvmfoundation is a very simple MVVM framework, and if you find it difficult to study the source code, you can start with this framework, which is simple and concise.

8, Append: Support Plug-in dependency injection MEF

: http://mef.codeplex.com/

The source code is as follows:

Figure 10

9, how to make full use of these frameworks

Above we have introduced the seven MVVM Framework + support plug-in Dependency injection MEF, in fact the other three framework WPF application Framework (WAF), calcium, COREMVVM (Basic MVVM Framework) is also worthy of study, due to the relationship between time and energy, the three framework of the Templars did not carry out a careful analysis, just a cursory look at the basic functions.

Other frameworks such as Onyx, Nroute, Nito MVVM, Ocean, goodlight don't pay much attention, and interested friends can choose one or more of these frameworks as research and learning, but still recommend a framework for studying the mainstream, After all, the mainstream framework of the development team and maturity are relatively strong.

Seeing so many MVVM frameworks, how do we learn and use them? In short, it can be summed up in the following words:

1, according to the specific project selection of the appropriate framework, the team and the project has a small, so you have to choose the specific framework according to these, in fact, after all, a few framework functions are similar.

2, the framework does not have to study too much, as long as it applies to the project, especially skilled use and according to the TDD test code provided to trace its principle.

3, the framework is not omnipotent, for some applications and functions can be extended to the framework, which is also one of the biggest benefits of open source.

According to the framework of the study, I also summed up several points:

1, first look at the framework of the relevant introduction, to understand the relevant background, function, architecture diagram and other relevant information-understanding.

2, according to the introduction to view and debug the framework provided by the example-familiar with the function.

3, write some of their own related projects, mainly familiar with the framework, if it is urgent to do projects, the latter can be introduced into the project-specific use.

4, according to the detailed unit test provided by the framework to study its source code, which is my favorite research on these open source framework reasons-the principle of analysis.

5, through the above steps to carefully analyze its principles and details-ready to reproduce.

6, I also based on the previous ideas to repeat the development of this framework, it is best to use the tdd--framework to restore shortcuts.

Above we talked about some of the open source framework knowledge, the next step we have to develop an MVVM framework, on the one hand is a summary of knowledge, on the other hand is also the re-refinement of knowledge, but also to raise their awareness to another level, immediately following.

10. Develop the MVVM framework yourself

As a result of the previous set of framework, but has not been refined, so temporarily not ready to share (mainly WPF and Silverlight version of the replacement is more frequent and not add templates and IntelliSense). For developing a set of MVVM frameworks, here are a few things to do:

1, to be able to solve the strong association between model, view and ViewModel, this is also the core function, especially view and ViewModel, whether using IOC container or MEF is OK.

2, the processing of commands and attached events, the command encapsulation, to satisfy the multi-parameter, method filtering, generics, asynchronous callback, etc., to encapsulate the attached event, making it as simple as using a command.

3, because view and ViewModel are weakly associative or unrelated, how do you make them communicate? This requires the messenger mechanism to be added.

4, the previous introduction of the message mechanism (typically static processing), how to manage, instantiate, clear the message? Here we have to set up a message mechanism.

5, because the previous use of weak association or no association, and the introduction of the message mechanism, so the operation must be logged, otherwise the problem can not quickly locate and trace the cause.

6, how to unify the management of Observableobject, Propertyobserver and other such objects? So you have to set up a change system.

7, to encapsulate common functions and operations, to provide some common library and UI helper.

In short, the development of the MVVM framework can not be perfection, as long as the appropriate project on the line, do not want to complete the framework once, in the use of constantly expanding according to demand is the wise. Additional three points to develop the MVVM framework experience:

1, take full advantage of other open source framework, study the shortcomings and advantages of each framework, and then put ideas through their own framework, of course, some commonly used function code can be directly borrowed from.

2, for such a large framework, the use of tdd+ repeatedly refactoring will undoubtedly improve the development efficiency, but also improve the maintainability and stability of the framework, which is also a prerequisite for the team to use.

3, the framework uses a number of common design patterns that allow the framework to be more extensible while reducing development costs and increasing maintainability. such as the Observer mode (Message publishing, subscription, triggering), the mediator mode (direct communication of the class to the middle class to deal with, isolated coupling), the appearance of the mode (provide a simple interface, a large number of internal encapsulation, so that can be used for easy and powerful purposes), Decorative mode (the original has been stable function module, if not change the original structure on the basis of expansion, no doubt this is a good practice) and so on.

----------------------------------------------------------------------------------------

Here are a variety of open source controls that are not covered.

Fluent Ribbon Control Suite


Microsoft Ribbon for WPF


Avalondock


PropertyEditor for WPF


WPF Property Grid


Propertyinspectorview


WPF Dynamic Data Display


Swordfist WPF Charts


WPF Toolkit


Avalonedit

WPF Open Source Collection

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.