Sharing MVVM and MVC models?

I am currently working on a project that has a fairly standard decoupled structure:

Repositories → Services → View Models → Views

Repository and service levels use POCO objects. Presentation models are built from these objects and call service methods, and then passed to the views.

I have two foreground projects, one web application using MVC3 and one desktop application using WPF. View models are contained in a stand-alone class library, since most of them are the same for both applications. (There are a few exceptions, but they are addressed using specific virtual machines for each project)

I am currently on the ground work and the working part of MVC working. Now I look at the WPF side and think about using the MVVM light toolkit.

My question is, given that view models are shared between MVC and WPF applications, is the MVVM light toolkit (or any other toolbox) suitable? Is there any reason that the MVVM light toolkit should not be used with MVC3?

I searched the language for a long time and did not find anything specific. Thanks in advance for your thoughts.

+4
source share
1 answer

IMHO the answer is that you cannot successfully exchange ViewModels between MVVM and MVC. Despite the fact that they are called the same, they are very adapted to a specific implementation. For example, you need to implement commands, rely on two-way binding, etc., when you are writing virtual machines for WPF, none of which are related to MVC. MVVM Light helps you achieve MVVM with WPF / SL, again not related to MVC at all.

I have the same scenario as yours, except my web project, these are standard web forms, not MVC. I share my .Business, .Model project links between my .Web and .Desktop projects, but everyone obviously does this on their own with the results of your business (services if you use them). I am very fresh for WPF, if I am mistaken in my assessment, I hope someone will correct me.

+5
source

Source: https://habr.com/ru/post/1385239/


All Articles