Tuesday, December 21, 2010

NetMonitor. Choosing MVVM framework

In the previous post I created a sketch of my small application with the help of Microsoft Expression Blend 4. Among other great features of the development suite there is a one that makes Blend outstanding -- it produces working XAML files, so every single UI screen in your sketch is represented as a separate UI control and the corresponding XAML is more or less ready for copy-pasting to the real application. This makes Blend the most preferable suite for sketching of WPF applications.
Let’s go further. When we are speaking about WPF we mean MVVM pattern and vice versa. What is MVVM? It is a concept that is derived from Model-View-Presenter (Model-View-Controller) pattern. There are several great articles about it, for example, I’d recommend this one and this one. AFAIK, there are two featured MVVM frameworks: GalaSoft MVVMLight & Caliburn, both of them are targeting WPF & Silverlight. I chose the first one, MVVMLight, as a base for my application because it is said that the framework supports designing in Blend, and that’s what I want.
So, I installed MVVMLight and created a new project based on MVVMLight WPF Template, added HostViewModel class, which describes the required information about a host and its health, and MainViewModel class that contains a collection of HostViewModel instances and a pair of commands, Start & Stop, which are derived from RelayCommand. After that I adapted the above-mentioned “Screen_1.xaml” from the sketch project. Here it is:
NetMonitor 02
For now, commands do nothing and the hosts information is static rather than live. Nevertheless, after a short period of work I’ve got a prototype that is written on WPF & MVVM and even shows something.
So, the UI part of the requirements is almost done. In the next posts I’ll try creating a Ping service and make use of it with the help of Start and Stop commands.

2 comments:

  1. By the way, it's a good idea to have a special guy in a team whose responsibilities is just to draw XAML forms and controls in expression blend. We already have one and are looking to another one :)

    ReplyDelete
  2. OK, I know where to apply for a job after I get more familiar with the tool =)

    ReplyDelete