Do a Google search on MVVM frameworks and you will find quite a few frameworks available for Silverlight development. Some simple and easy to use with others that are complicated and add to the learning curve. Amazon has at least 3 or 4 books on MVVM. There are tutorials, videos, and blogs galore about MVVM and MVVM frameworks. So which framework should one use? Well my choice would be one that is flexible, easy to use, small learning curve, and be maintained by the developer and not end up on the scrap heap of discarded projects.
I looked at approximately a half dozen Silverlight frameworks, such as Galasoft, Caliburn, Prism, Catel, Simple MVVM Framework, and even Lightswitch. While I am sure that all of them have a useful purpose, and the developers developing them are producing a great product. None of them were for me. I needed something that was simple and easy to learn. I am already learning Silverlight, the software I use for my Entity Framework (Ideablade), and my UI controls (Intersoftpt ClientUI) why do I want to add another piece to my learning time. The majority of them were not that simple and when they create applications, they have the look and feel of templates. Also most of them were created and maintained by individuals and small groups. Would they be around in a few years? In addition many of them did not provide the full range of MVVM features. Please understand I am not knocking any of the products or their developers. They just did not fit my needs.
The other alternative was that I could write my own MVVM framework. Right! I am busy enough developing software for paying clients. How could I devote the time to writing a framework even if I knew how? Then the thought occurred to me, did I really need to use an MVVM framework? No. I just needed to keep my code separated into view, view models, repositories etc. I needed the ability for the view to notify the view model that a button was clicked or a field lost focus, or a drop down item was selected etc. I needed to keep any code in the code behind .cs to a bare minimum or none. And I needed an Event Aggregator.
An Event Aggregator is a controller class for handling all the commands coming in from the many objects in an application and forwarding those commands to the target objects. While it not absolutely necessary to have an Event Aggregator, it provides a level of indirection to the command process. It centralizes all the commands into one place. In addition a lot less memory is used with the Aggregator than with multiple observers.
So if I did not use an MVVM framework and I did not create my own, how did I solve the problem of separating the views from the view models, passing commands from the one to the other, and having an Event Aggregator in Silverlight. I use ClientUI 5 from Intersoft.
Every control that comes with ClientUI is built with the MVVM architecture pattern and allows for loose coupling between the view and view model. In addition, the controls integrate nicely with Ideablade Devforce, an entity framework tool. So I build my views with Intersoft ClientUI and my entity framework uses Ideablade Devforce.
ClientUI 5 comes with many Visual Studio templates that help the developer easily jump start an MVVM application and there are many tutorials and samples showing how to use the controls in an MVVM pattern, including the excellent “Contacts” application which show how to integrate ClientUI and Ideablade.
Over the next couple of weeks this blog is going to develop a full blown inventory tracking application using just Ideablade Devforce and ClientUI 5. The application will be fully MVVM compliant with no framework needed.
I am not an employee of either Ideablade or Intersoft. I am a software developer and president of a consulting company.