MVVM is a great technology, but it can still throw you a lot of curves. Its real power comes from the fact that you can test all of the pieces (Models, View Models, Primatives, etc.) individually without the need to screw them all together. Even so, MVVM can be a royal pain in the ass, especially given all of the “separation of concerns” issues, combined with it’s relatively high part-count. With that said, in a WPF desktop-application world, MVVM is the way to go. Or to hear me tell it: “The Bomb!”
One of the things that makes MVVM easier to go down is a great development library. Just to be clear, the SquidEyes.MVVM library that I’m demoing has yet to become great. It’s quite good though, and—to be frank—my private build is even better, but just to be clear, it’s YTBG. With that said, the primary reason I created the library was to support a combo-box (or what I like to call a “selector”) driven Master/Detail form; something that no other MVVM library seems to do.
The window that you see to the right is a Plain-Jane WPF window; or to use MVVM-speak, a View (named appropriately: MainView). The view gets driven by a relatively small amount of code int the ComboSelector project, but the real magic happens in my SquidEyes.MVVM library.
There are way too many fiddly bits to go into in print. Therefore, I’ve create this video to walk you through both of the projects.
As I said in the video, there are plenty of excellent MVVM libraries out there. I would highly recommend you check out Tony Sneed’s excellent SimpleMVVM libraries (for WIndows Phone and SilverLight, as well as WPF). It would be fair to say that I got some of my best ideas from him, although little if any code. Even so, he deserves your support. For the true MVVMoisseur, you may also want to check out MVVM Light, MvvmCross, Catel and Prism.
In any case, I’d love to hear brack from, so be sure to tell me what you think. Enjoy….