Wpf Prism application architecture with MVVM pattern

I am currently introducing Prism for a new Wpf application and using the MVVM pattern. My initial approach to structuring a Wpf application was to add one project to hold the model classes, one to hold the viewmodel classes, etc. They can be separated later to avoid using different logical components in the same project. However, it strikes me as a bad structure when using Prism (and maybe generally ...).

In Prism, you want to structure things into different logical units, where anything related to the same will be placed in the same unit. So this tells me that I should put everything related to the logical part of my application into a module for that part. It can contain several different views for that component, the associated view model, and the required model classes. Using this approach, I would, however, end up with a model scattered across my solution. Since the model will be database bound, this is kind of a bad approach in my opinion. I am using NHibernate, so the database will not really be that "visual".

So I see three different structures. Are any of them required? Or is there another way to structure the application?

  • Projects "Model", "ViewModel", and one for storing UserControls. Etc ..
  • One design logic part - including both the linked view, the viewmodel and the model for that part.
  • One design logic part - including view and viewmodel, but the model is defined in a separate project. Perhaps even one project for all model classes if they have a logical relationship.

Any opinions are appreciated!

+2


source to share


1 answer


Putting your model in a separate project is fine. I would say he would recommend it if it is large enough to really benefit from the prism style architecture. The model is not limited to the vertical silos V and VM, but to the lower level, which is below all.



Your views and views make sense to live next to each other. You may find reuse of views or gaze models, but not stressful if you don't. However, point of view is not always tied in the universe to a particular representation model and vice versa. For example, I have a view model that displays all sales and a view model that filters the current quarter, but I can set both to the same view. On the other hand, I have a pie chart versus a bar chart on the same view model. So splitting them is not like cut and dried. However, you may find larger chunks than just model view / view pairs. Sales and customer management, etc.

+2


source







All Articles