[英]How to bind the ViewModel for a windows phone 8 messaging app
[英]Hot to design the ViewModel for a windows phone 8 pivot app
我正在使用MVVM Light创建Windows Phone 8 Pivot应用程序,我想知道如何设计视图模型。 应用程序的每个枢轴(总共3-4个)都可以处理不同的数据集合。
我正在考虑的选项是:
您说哪种选择更好?
只有一个视图模型,然后每个视图模型都有单独的集合。 具有必要的收集项目以绑定到枢轴项目。
视图
<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}"
/>
视图模型:
public class MainModel
{
public ItemViewModel Collection1 { get; set; }
public void LoadData()
{
Collection1=CreateCollection();
设置适当的数据上下文。
教程: 数据绑定和数据透视教程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.