WP7 MVVMCross Detect RequestClose or BackKeyPressed inside ViewModels

元气小坏坏 提交于 2019-12-11 01:58:36

问题


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?

Regards, Dan


回答1:


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

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.

For example:

  • 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.

  • 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?


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



来源:https://stackoverflow.com/questions/10515990/wp7-mvvmcross-detect-requestclose-or-backkeypressed-inside-viewmodels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!