This project is read-only.

Introduction

The purpose of the Simple MVVM Toolkit is to provide what you need to build Silverlight applications using the Model-View-ViewModel design pattern, which separates the visual representation (the View) from the data (the Model) using an intermediate class (the View-Model). The View binds directly to the View-Model, which presents the data model in a way that the View can use, for example, by translating a property from one type to another (e.g., Boolean to Visibility) and which provides behavior via public methods that the View can invoke, either from XAML or code-behind. Elements within the View can also bind directly to Model elements that are exposed by the View-Model, for example, a collection that populates a combo box. The Model should not be aware of the View-Model, and the View-Model should not be aware of the View. Loose coupling between these components makes for better maintainability, because you can modify one part without impacting the other parts, and testability, because you can isolate one part to test it independently. It also offers designability by allowing designers and developers to work more independently from one another.

Toolkits

Implementing MVVM in your Silverlight application requires the assistance of some helper classes.  While you can write these yourself, it’s helpful to use a toolkit that includes these classes, which cooperate with one another to support your development objectives.  Toolkits vary widely in philosophies, supported features, complexity, and supporting documentation and samples.  Which toolkit you select depends not only on your requirements but on what you’re trying to achieve by applying the MVVM design pattern, as well as the inclusion of productivity tools such as Visual Studio templates and code snippets.

Guiding Principles

The primary guiding principle of the Simple MVVM Toolkit is simplicity.  Not only does this make it easy to understand and use, but it reduces the overall complexity of your application, which makes it easier to extend and maintain.  I take a very pragmatic approach, seeking a balance between architectural purity and ease of development.  The target audience for this toolkit is a development shop building anything from small to large Silverlight, WPF or Windows Phone applications, but which may not have a team of graphic designers using Blend to create the views.  Therefore, zero code-behind, while allowed by the toolkit, is not a primary objective.  Likewise, while I include samples using Managed Extensibility Framework (MEF) and Dependency Injection (Unity or NInject), the toolkit and examples do not require this.  And while I provide a sample using WCF RIA Services, the toolkit does not require this.  Because Microsoft has positioned Silverlight as the preferred platform for business application development, the main sample uses an n-tier architecture with a WCF service that uses the Entity Framework to retrieve entities from a database (our good ol’ friend Northwind).

Components

The Simple MVVM Toolkit consists of a set of helper classes, Visual Studio project and item templates, and code snippets.  The helper classes are located in the SimpleMvvmToolkit assembly, which you can reference from your project, or you can if you wish include the SimpleMvvmToolkit project in your Visual Studio solution, which is probably a good idea when you are getting to know the framework.  There are Visual Studio project templates, which provide completed sample projects with all the classes you need to get started.  There are also Visual Studio item templates, which provide boilerplate code for view models and also a view model locator classes.  And there are both code snippets, for inserting things like bindable properties, and xml snippets, for settings things like the View DataContext and using event triggers.

Installer

The toolkit comes with a handy installer, which registers the toolkit assemblies so that they appear in the Visual Studio Add Reference dialog.  It also copies all the Visual Studio project templates, item templates and code snippets to their proper location under the current user’s Documents folder.  And it gives you zip files with both the sample apps and source code.

Last edited Apr 14, 2011 at 1:52 PM by tonysneed, version 8

Comments

No comments yet.