是MVVM死在Windows 8商店应用程序? [英] Is MVVM dead in Windows 8 Store Apps?

查看:172
本文介绍了是MVVM死在Windows 8商店应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习有关Windows 8商店应用程序。

I have started learning about Windows 8 Store Apps.

我从Silverlight和WPF编程早期,人们适应了MVVM概念回忆,现在我不知道我应该用我学到的东西当时还是不行。

I recall from Silverlight and WPF programming earlier that people adapted the MVVM concept and now I am not sure if I should use what i learned back then or not.

我添加了一个参考GalaSoft.MvvmLight并创建了一个视图模型,并把它添加到我的XAML所建议的:

I added a reference to the GalaSoft.MvvmLight and created a ViewModel and added it to my xaml as suggested by:

DataContext="{Binding Source={StaticResource Locator}, Path=Welcome}"

它看起来像微软包含某种模型视图实现在LayoutAwarePage:

It looks like Microsoft included some kind of ModelView implementation in the LayoutAwarePage:

protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
    // TODO: Assign a bindable collection of items to this.DefaultViewModel["Items"]
    //  DefaultViewModel["WelcomeTiles"] = WelcomeTiles;
}

可如果下面的datacontext已设置进行访问。

which can be accessed if following datacontext have been set.

<DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" />

所以,现在我不能确定我是否应该创建ModelViews我记得他们,用MVVMLight或者只是在code隐藏文件中的数据添加到DefaultViewModel。

So now I am unsure if I should create ModelViews as i remember them, by using MVVMLight or just add the data in code-behind files to the DefaultViewModel.

什么是人民与既有经验?我刚刚开始,我的下一个目标是添加处理程序时,一个项目被点击在GridView的 - 它上面的路径就会让这样做的一个简单的方法

What are peoples experience with both? I have just started and my next goal is to add handlers for when a item is clicked in the GridView - which of the above paths will let do so in a easy way?

推荐答案

否,MVVM永远不会死!

模型 - 视图查看模型是一种设计模式,所以它是不依赖于特定的框架或实施。然而,这是一个用户界面设计图案最方便与支持数据绑定UI框架来使用。

Model-View-ViewModel is a design pattern, so it is not dependent on a specific framework or implementation. However, it is a UI design pattern that is most convenient to use with UI frameworks that support data-binding.

Windows 8的地铁应用程序包括XAML和有约束力的框架,这一点很像Silverlight和WPF。出于这个原因,MVVM是绝佳的选择来管理您的code。

Windows 8 Metro apps include XAML and a binding framework which is much like Silverlight and WPF. For this reason, MVVM is excellent choice for managing your code.

您已经发现了 LayoutAwarePage 的code中的这个博客帖子。这是企图使Windows 8地铁应用程序开发变得更容易通过提供不同的存根实现。此页面包含一个 DefaultViewModel ,这是一个可观察到的字典。

The code you have discovered in LayoutAwarePage is described in this blog post. It is an attempt to make Windows 8 Metro app development easier by providing various stub-implementations. This page includes a DefaultViewModel, which is an observable dictionary.

就个人而言,我不会用它!

Personally, I wouldn't use it!

这篇关于是MVVM死在Windows 8商店应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆