WP7 MVVM交叉检测ViewModel内部的RequestClose或BackKeyPressed [英] WP7 MVVMCross Detect RequestClose or BackKeyPressed inside ViewModels

查看:45
本文介绍了WP7 MVVM交叉检测ViewModel内部的RequestClose或BackKeyPressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种看法.我从一个导航到另一个,在另一个导航中,我调用RequestClose或使用返回键.如何在第一个ViewModel中检测到这些事件?

I have two view. I navigate from one to the other and in the other I call RequestClose or use the back keypress. How can I detect in the first ViewModel these events?

关于, 丹

推荐答案

默认情况下,MvvmCross框架不会告诉您有关此事件的信息.

By default the MvvmCross framework doesn't tell you about this event.

您需要设计出其他方法让ViewModel知道它需要执行某些操作.

You'll need to work out some other way of letting the ViewModel know that it needs to do something.

如何执行此操作取决于您要寻找的实际事件.

How you do this depends on what the actual event is that you are looking for.

例如:

  • 如果第二个ViewModel更改了基础模型中的某些数据,则可以通过数据层中的事件将其传递回第一个ViewModel.

  • if the second ViewModel changed some data in an underlying model, then this might be communicated back to the first ViewModel through an event from the data layer.

如果第二个ViewModel以某种方式更改了一些更短暂的东西(类似较少的模型),则您可以实现某种消息传递机制(使用TinyMessenger之类的东西)以允许ViewModels进行通信.

if the second ViewModel was somehow changing something more transitory (less model like) then you might implement some sort of messaging mechanism (using something like TinyMessenger) to allow ViewModels to communicate.

您能再说说您的活动是什么吗?

Can you say any more about what your event is?

更新...作为示例,这是我可能会为facebook做的事情的类型- https://github .com/slodge/facebookExample (仅已签入WP7!)

Update... as an example, here's the type of thing I might do for facebook - https://github.com/slodge/facebookExample (WP7 only checked in!)

这篇关于WP7 MVVM交叉检测ViewModel内部的RequestClose或BackKeyPressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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