工作的MVVM示例 [英] Working of MVVM example

查看:103
本文介绍了工作的MVVM示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我从下面的URL下载了一个例子



我对如何查看感到困惑在此示例中,当ContentControl绑定到ApplicationView.xaml中的ViewModel时,它们会被加密。代码视图中没有任何地方与ViewModel相关联。



有人可以解释一下这个吗?



http://rachel53461.wordpress.com/2011/12/18/navigation-with -mvvm-2 / [ ^ ]

推荐答案

如果在资源中定义具有DataType属性但不是Key属性的DataTemplate,则将其视为隐式DataTemplate 。这意味着,它将在WPF尝试呈现指定数据类型的对象时使用。



我的示例包含没有为每个ViewModel定义Key属性的DataTemplates,所以当WPF尝试将ViewModel渲染到ContentControl.Content区域时,它使用指定的DataTemplate代替=)
If you define a DataTemplate in your Resources that has a DataType property but not a Key property, it is considered an Implicit DataTemplate. This means, it will be used anytime WPF tries to render an object of the specified DataType.

My example has DataTemplates without a Key property defined for each of the ViewModels, so when WPF tries to render the ViewModel into the ContentControl.Content area, it uses the specified DataTemplate instead =)


这篇关于工作的MVVM示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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