FrenchData
FrenchData

Reputation: 630

How many view models for a panorama page

I'm starting to play with the windows phone 7 panorama control.

I looked at the panorama project template provided in visual studio and saw that the two panorama items use the same view model (and in fact the same data from the model).

How is it in real world applications? Should I best use one view model per panorama item or is it best practice to have only one view model for the complete panorama?

Upvotes: 2

Views: 612

Answers (3)

Den
Den

Reputation: 16826

It really depends on the application. What you saw in the default template is simply there to show you the basics of a MVVM-based design. I personally use a ViewModel for a set of pages that have a similar purpose (e.g. managing media content). There is a single ViewModel locator (per application) that ties them all together.

Bottom line - it is more of a question of preference, as long as the concerns are separated.

Upvotes: 0

Rune Grimstad
Rune Grimstad

Reputation: 36320

It depends on what you are doing.

In most cases I would have separate view models for each page, but if for instance each page is very simple then you may not need it.

An example could be a panorama with each page displaying an image. In this case you might get away with binding the the panorama control to a single list of images.

Upvotes: 0

Jesus Rodriguez
Jesus Rodriguez

Reputation: 12018

I think that is one View Model per page (a panorama is just a control, not multiple pages). So one ViewModel on a page and every PanoramaItem will use it (My opinion).

Upvotes: 1

Related Questions