Reputation: 1316
I'm currently working on a project that has a fairly standard decoupled structure like this:
Repositories -> Services -> View Models -> Views
The Repository and Service layers use POCO objects. The view models are built from those objects and calling service methods and then passed to the views.
I have two front end projects, one web app using MVC3 and one desktop app using WPF. The view models are contained in a standalone class library as the majority are the same for both apps. (There are a few exceptions but these are dealt with using specific VMs for each project)
Currently I'm at the stage of having the ground work laid and the MVC side all working. I'm now looking at the WPF side and thinking of using MVVM light toolkit.
My question is: Given that the view models are shared between the MVC and WPF apps, is MVVM light toolkit (or any other toolkit) appropriate? Is there some reason that MVVM light toolkit should not be used with MVC3?
I googled around for quite a while and found nothing concrete. Thanks in advance for your thoughts.
Upvotes: 4
Views: 1023
Reputation: 6022
IMHO the answer is that you will not be able to successfully share the ViewModels between MVVM and MVC. Even though they are called the same thing they are very much tailored to the particular implementation. For example, you'll need to implement commands, rely on two way binding, etc. when you write VMs for WPF, none of that is relevant to MVC. MVVM Light helps you to achieve MVVM with WPF/SL, again not relevant to MVC at all.
I am in a similar scenario as you are, except my web project is standard webforms and not MVC. I share my .Business, .Model project references between my .Web and .Desktop projects, but each obviously does it's own thing with the results of the business (services if you use them) layer. I'm very fresh to WPF, if I'm wrong in my assessment I hope someone will correct me.
Upvotes: 5