MVVM in VB.Net - Lesson 1: What is MVVM?

Update: MVVM ViewModel Injection tutorial coming soon!

I am in the process of creating a tutorial to form a classic M-V-VM project similar to Prism/MVVM Light toolkit. I have looked through these frameworks, and I feel that the programming it does is intensive, and frankly overbearing. These frameworks use a process called ViewModel Injection, where the model is a skeleton of the data to be used, the ViewModel processes all the logic and injects the data to the View (GUI).

I am a simpleton, and believe in the K.I.S.S. (keep it simple, stupid) rule. Since I am working on a project that uses this process, I will be more than happy to share my findings with you. The tutorial will be similar to this tutorial. It will NOT use outside frameworks. I feel the framework should always be embedded in the application (or solution) so it can be modified to the users' (and programmers') demands. Also, with everything in tact, any programmer behind you can easily see how the application works, and not have to rely on outside sources to figure it out. In other words, K.I.S.S.

The Broad Stroke

Model-View-ViewModel design pattern started out as a presentation pattern introduced by Martin Fowler, and was built upon by Josh Smith. The MVVM pattern targets the Windows Presentation Foundation (WPF), which is part of Microsoft’s .NET Framework.

The point of MVVM is to separate the Presentation Layer (View), the Logic Layer (ViewModel), and the Data Layer (Model). With the Presentation Layer separated from the Logic Layer, you can easily create application that will perform on many platforms with little or no additional coding. For example, you can create an application for Windows platform, and use the same Logic Layer (and in some cases the Presentation Layer) for the Windows Mobile platform, or even Silverlight.

Using this pattern also allows you to create a browser like application complete with back and forward navigation. In addition, you can harness the power of WPF's data binding features, such as data validation and data conversion.

Tutorial Overview

MVVM or Model-View-ViewModel is a new programing paradigm that is centered to WPF. This design allows you to unit test your projects without the UI, and separate the application into layers. Allowing you or your team to update the application quickly as well as unit test successf This design, however, is not set in stone, and can be varied in many ways.

The following tutorial is designed to show you one way to design effective MVVM applications in VB.Net (2008 and later). I have created a project template to help you and can be found here: MVVM Project Template.

NOTE: I have create a MSVS extension for Model Injeciton. It can be found in the Visual Studio Extension Gallary.
MVVM Model Injection Solution Structure

More by this Author


Click to Rate This Article
working