2

I am making an mvvm application for the uwp platform and I am looking for advice on the following matter.

Take for example the windows 10 e-mail application, which when full screen displays both the e-mail list and e-mail content in one page, while in smaller form factors the content is displayed in separate pages.

What is the best way to correlate views with viewmodels in this scenario?

My thoughts are

  1. A big view model which will be the data context for all the views in this scenario.

  2. Two view models, one for the e-mail list and one for the e-mail content, set as the data context for different parts of the page or different pages.

  3. Three view models. The two view models from the previous point and another one to coordinate them.

What do you think is best? My problem mostly stems from the fact that in one case you actually navigate to another page, and have to put logic in navigation events that don't exist in the other case.

0

I know it is a bit late for the question but, FWIW, here is my answer:

Your second approach with the viewmodels does make sense as you have two different things to present but not with different viewmodels for each of the pages. One Viewmodel for the content.

In my view, the change to the way the email content is presented is not UI logic in the same sense when you have a wizard and you press the Next button and you may skip pages. What you describe is a matter of UI design.

What you may, though, need to be able to do is to partially retrieve the content of the email. That would be a function or a method in the viewmodel of the email content.

Given, the above viewmodel a UI designer can change the design of the form in any way they like.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.