WP7 MVVMCross Detect RequestClose or BackKeyPresse

2019-07-20 09:11发布

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条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-20 09:39

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!)

查看更多
登录 后发表回答