开发者

What is the critieria for a view in a WP7 app in the MVVM pattern?

I'm building a WP7 app, as a way to better understand the MVVM pattern.

As I understand it, the MVVM pattern decouples the UI from the Business Objects, in a fashion that is similar to MVC.

This application pulls together data from variety of sources (Flickr, Facebook, Sports, etc) and displays it on a single application page using a Panorama Control.

For the MVVM pattern, I'm trying to underst开发者_如何学Goand what should be considered a view.

If my Panorama Control contains other custom user controls, is each control considered a view, given that each has it's own XAML? Or would a single Phone Application page be a view, similar to how a single HTML page might be a view in MVC?


There is no accurate definition of the granularity of views per the MVVM pattern. So choosing what gets to be a seperate view (with a viewmodel to accompany it) is a design choice.

In your example with a panorama with several other custom controls, I would normally make each control a view (with its own .xaml file) and its own viewmodel. I find it easier to make changes in my application when I split the user interface into several views+viewmodels.

I sometimes also have a whole phone application page as a view. Say if there is no group of UI components that naturally fit together, or the view is really simple.

I hope that helps, if not give more concrete examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜