c# - Hot to design the ViewModel for a windows phone 8 pivot app -


i creating windows phone 8 pivot app using mvvm light , wondering how design view model. each pivot of app (in total 3-4) work different collections of data.

the options considering are:

  1. have 1 mainviewmodel contains different collections different pivots. best practices read on mvvm mandate (this how understood them @ least) 1 view should have 1 viewmodel option comes naturally.
  2. have separate viewmodel each pivot , 1 mainviewmodel reference them. option makes more sense me in terms of separation , code structure. make bindings , command wiring little bit more tricky.

which option better?

have 1 view model , have separate collections each viewmodel. have necessary collection items bind pivot items.

view

<phone:pivot x:name="tutopivot"          selectionchanged="pivotselectionchanged">         <!--pivot item one-->         <phone:pivotitem header="{binding collection1.title}">             <!--double line list text wrapping-->             <phone:longlistselector margin="0,0,-12,0"                 selectionchanged="longlistselector_selectionchanged"                 layoutmode="grid"                 gridcellsize="150,150"                 itemssource="{binding collection1.items}"                 itemtemplate="{staticresource newsoundtemplate}"                                     /> 

viewmodel:

public class mainmodel {     public itemviewmodel collection1 { get; set; }     public void loaddata()     {         collection1=createcollection(); 

make appropriate data context.

tutorial: data bound , pivot tutorial


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -