Question

I have seen lots of blog about MVVM vs MVC and blogs that says thay MVVM is like MVC extension in Windows.

I have one design issue, I have made one win application that uses MVVM , now i have to create a same application in Web, so i decided to MVC pattern in Asp.net, but now again i am stuck at point.

how to reuse ViewModels in MVC? because ViewModel has imports namespace System.Windows.Input.

Is there any alternative soultions?? My primary requirement is reusing application logic?

I have used http://waf.codeplex.com/ WpfApplication framework as refrence.

Thanks in advance.

Was it helpful?

Solution

The fact is that the two aren't interchangeable. Nor are they supposed to be (in a practical sense). Yes, you could create ViewModels that could also be reused in ASP.NET MVC. But the amount of abstraction you would have to incorporate would make the exercise useless.

You should not waste your time worrying about this incompatibility, working hard to reduce/eliminate it.

What you should do is move truly reusable code that has no dependencies on either WPF or ASP.NET into reusable libraries. This code is what should be reused in both applications. Your ViewModels and Controllers belong with the application frameworks they were designed to service.

OTHER TIPS

Your business logic should be in your Models, not in your View Models. So it's the Models you want to reuse, nothing else. View Models are specific to your Windows application, and are equivalent to Controllers which are specific to a web application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top