CoreMVVM: A basic MVVM framework

 CoreMVVM download (for those in a hurry :) )

The MVVM Toolkit is a pretty barebones template for MVVM and is a good place to start with if you are new to this pattern. Over time, as i played around with this toolkit, the library grew in size. Its been useful for me - so i thought i might as well share it out :) .. The code is an extension of the Toolkit and pulls in a lot of concepts from other fameworks out in the wild... Will have a subsequent post on these frameworks. So getting back to this library, it includes support for:

  • Delegating Commands\Keybinding
  • Messaging between VM's
  • Handling events as commands with attached behaviors
  • Handling dialogs (and more) as services

A very simple sample is also included to show the various parts in action. (Nothing fancy)

To make the writing of commands with Attached behaviors I have included Damian's code snippet, which you place under Documents\Visual Studio 2008(10)\Code Snippets\Visual C#\My Code Snippets. The shortcut for its usage in code is cmdbehavior

 You could as well just run the installer. If you do use the installer edit the snippet to include CommandParameter = e;  at the beginning of the last function (On$EventType$)

You would need to fill 4 parts in the snippet:

  • CommandAction - Descriptive name of what the command performs
  • BehaviorName - Attached behavior name (this hooks the event)
  • ControlType - Type of control to which the command will attach
  • EventName - Name of the control event that the behavior hooks up

Hopefully you'll find the library useful. Also, this library by no means covers all possible scenarios. Have fun coding.

As mentioned earlier the library uses code\concepts from the following frameworks

Cinch - for the Services and ViewModelBase
Messaging - from Marlons\Josh's mediator posts
Prism - for the commanding model

 

CoreMVVM Download Link for the library\demo

Share this post