我已经开始学习Windows 8商店应用程序了.
我记得早些时候从Silverlight和WPF编程中人们改编了MVVM概念,现在我不确定我是否应该使用我当时学到的东西.
我添加了对GalaSoft.MvvmLight的引用并创建了一个ViewModel并将其添加到我的xaml中,如下所示:
DataContext="{Binding Source={StaticResource Locator}, Path=Welcome}"
Run Code Online (Sandbox Code Playgroud)
看起来Microsoft在LayoutAwarePage中包含了某种ModelView实现:
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
// TODO: Assign a bindable collection of items to this.DefaultViewModel["Items"]
// DefaultViewModel["WelcomeTiles"] = WelcomeTiles;
}
Run Code Online (Sandbox Code Playgroud)
如果设置了以下datacontext,则可以访问该文件.
<DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" />
Run Code Online (Sandbox Code Playgroud)
所以现在我不确定是否应该创建ModelViews,因为我记得它们,使用MVVMLight或只是将代码隐藏文件中的数据添加到DefaultViewModel.
两国人民的经历是什么?我刚刚开始,我的下一个目标是在GridView中单击项目时添加处理程序 - 以上哪个路径将以简单的方式执行此操作?