我正在创建一个使用MVVM的Windows 8数据透视应用程序,我想知道如何设计我的视图模型。应用程序的每个枢轴(总共3-4个)都使用不同的数据集合。
我现正考虑的方案如下:
你说哪种选择更好?
发布于 2014-03-10 06:02:35
只有一个视图模型,然后为每个视图模型拥有单独的集合。有必要的集合项绑定到枢轴项。
视图
<phone:Pivot x:Name="TutoPivot"
SelectionChanged="PivotSelectionChanged">
<!--Pivot item one-->
<phone:PivotItem Header="{Binding Collection1.Title}">
<!--Double line list with 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();创建适当的数据上下文。
教程:数据绑定和枢轴教程
https://stackoverflow.com/questions/22292670
复制相似问题