MVVM – Frameworks


Advertisements


In this chapter, we will discuss MVVM toolkits or frameworks that are available. You can also use these frameworks so that you don't have to write a bunch of repetitive code to implement the MVVM pattern yourself. Here are some of the most popular frameworks −

  • Prism
  • MVVM Light
  • Caliburn Micro
MVVM Frameworks

Prism

Prism provides guidance in the form of samples and documentation that help you easily design and build rich, flexible, and easily maintained Windows Presentation Foundation (WPF) desktop applications. Rich Internet Applications (RIAs) built with the Microsoft Silverlight browser plug-in and Windows applications.

  • Prism uses design patterns that embody important architectural design principles, such as separation of concerns and loose coupling.

  • Prism helps you design and build applications using loosely coupled components that can evolve independently but which can be easily and seamlessly integrated into the overall application.

  • These types of applications are known as composite applications.

Prism has a number of features out-of-the-box. Following are some of the important features of Prism.

MVVM Pattern

Prism has support for the MVVM pattern. It has a Bindablebase class similar to the one which is implemented in the earlier chapters.

It has a flexible ViewModelLocator that has conventions to it but allows you to override those conventions and declaratively hook up your Views and ViewModels in a loosely coupled way.

Modularity

It is the ability to break up your code into totally loosely coupled class libraries in parts and bring them together at runtime into a cohesive whole for the end user, while the code remains fully decoupled.

UI Composition/Regions

It is the ability to plug views into containers without the View that's doing the plugging, needing to have an explicit reference to the UI container itself.

Navigation

Prism has navigation features that layer on top of regions, like forward and backward navigation and the navigation stack that allows your view models to participate in the navigation process directly.

Commands

Prism has commands so they have a delegate command that's very similar to the MyICommand we have used in earlier chapters except it's got some extra robustness to protect you from memory leaks.

Pub/Sub Events

Prism also has support for Pub/Sub events. These are loosely coupled events where the publisher and subscriber can have different lifetimes and do not have to have explicit references to each other to communicate through events.

MVVM Light

MVVM Light is produced by Laurent Bugnion and helps you separate your View from your Model, which creates applications that are cleaner and easier to maintain and extend.

  • It also creates testable applications and allows you to have a much thinner user interface layer (which is more difficult to test automatically).

  • This toolkit places special emphasis on to open and edit the user interface into Blend, including the creation of design-time data to enable the Blend users to "see something" when they work with data controls.

Caliburn Micro

This is another small open-source framework that helps you implement the MVVM pattern and also supports a number of things out-of-the-box.

  • Caliburn Micro is a small, yet powerful framework, designed for building applications across all XAML platforms.

  • With strong support for MVVM and other proven UI patterns, Caliburn Micro will enable you to build your solution quickly, without the need to sacrifice code quality or testability.



Advertisements
E-Books Store