wpfmvvmbusiness-logic

Business Logics of projects under MVVM in WPF?


I am developing an application in WPF using the MVVM pattern. If I have Student as a data model, for example, where could I add the business logic like adding new Students, deleting Students and updating Student info, calculating marks and so on?

Does all the business logics come under the model or the viewmodel?

If it is in the model how can we do that? Any example code please? I need full code for an example!


Solution

  • Business logic should be part of of your model, as all of that code should be reusable across different technology platforms. For example, you may want to reuse your models across a web site in ASP.NET MVC, and a desktop application in WPF, so it wouldn't make sense to have business logic in your view models.

    View models should contain presentation logic which is specific to that particular application instance.

    As for example code, this will be specific to the domain that you are modelling, so you would have to ask a more specific question about what you are trying to model.