如何将ViewModel绑定到MvvmCross中的Windows 8“设置"窗格? [英] How do you bind a ViewModel to the Windows 8 Settings pane in MvvmCross?

查看:55
本文介绍了如何将ViewModel绑定到MvvmCross中的Windows 8“设置"窗格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找用于跨平台移动开发的MvvmCross.

I've been looking at MvvmCross for cross platform mobile development.

由于视图导航是通过调用ShowViewModel<>()完成的,因此您将如何在Windows 8中使用MvvmCross创建设置窗格(是用户控件)?

Since navigation of views is done by calling ShowViewModel<>(), how would you create the settings pane (which is a user control) in Windows 8 using MvvmCross?

推荐答案

MvvmCross提供了一种通用的ShowViewModel<T>导航机制,该机制使用Presenter在View上显示和设置DataContext.以这种方式显示的视图通常会覆盖整个屏幕",并受益于使用CIRS自动构建的ViewModel(请参见

MvvmCross provides a general ShowViewModel<T> navigation mechanism which uses a Presenter to display and set the DataContext on Views. Views that are shown this way typically cover the 'whole screen' and benefit from automatically constructed ViewModels using CIRS (see http://slodge.blogspot.co.uk/2013/03/v3-new-viewmodel-lifecycle.html)

但是,仅因为导航通常是使用ShowViewModel<T>完成的,所以这并不妨碍您以其他方式使用ViewModels. ShowViewModel<T>机制的常见例外是诸如iOS Tabbed和SplitView子代,WindowsPhone Pivot/全景项,Android子片段和对话框以及Windows8子窗格(如弹出按钮)之类的东西.

However, just because navigation is typically done using ShowViewModel<T> this doesn't prevent you from using ViewModels in other ways. Common exceptions to the ShowViewModel<T> mechanism are things like iOS Tabbed and SplitView children, WindowsPhone Pivot/Panorama items, Android sub-Fragments and Dialogs, and Windows8 sub-panes such as flyouts.

在Windows8的实践水平上,每个XAML UserControl都有一个DataContext属性,可以在代码中进行设置-这样您就可以始终:

At a practical level in Windows8, every XAML UserControl has a DataContext property which you can set in code - so you can always:

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