MvvmCross Moving from a ViewModel Event

I read about “ViewModel to ViewModel navigation” and “View Model Lifecycle” from here: https://github.com/MvvmCross/MvvmCross/wiki/ViewModel--to-ViewModel-navigation https://github.com/MvvmCross/MvvmCross / wiki / View-Model-Lifecycle

I can use the Init () or Start () methods to initialize the current ViewModel. I can also pass parameters from one ViewModel to another and get it in the Init () method.

So my question is: When I created applications for Windows phones, I used the "NavigateTo" and "NavigateFrom" methods. Init () is similar to "NavigateTo". But I did not find an alternative for the “NavigateFrom” method in mvvmcross, and I do not know how to reload the data when I move “back” to “Close (this)” or using the “Back” button on a Windows phone.

Could you give me a hint?

Thanks in advance!

updated

I found out that Messenger (the MvvmCross plugin) can help me inform the first ViewModel when another second ViewModel has changed the data (for example, add an item to the collection). Therefore, when the second ViewModel adds a new element, the ViewModel first reloads the data in the OnCollectionChanged (CollectionChangedMessage obj) method.

Stuart showed how to work with this plugin in NPlus1DaysOfMvvmCross / N-13-CollectABull-Part2. Link here: https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/tree/master/N-13-CollectABull-Part2

+1
source share
1 answer

But I did not find an alternative for the “NavigateFrom” method in mvvmcross, and I do not know how to reload the data when I move “back” to “Close (this)” or using the “Back” button on a Windows phone.

In general, you do not need to reload data in this event - since the ViewModel has already been created and initialized from the previous navigation in the forward direction.

If you want to update the ViewModel when navigating back, then the IVisible template in the N = 42 video may help, but you will need to add this to your View and ViewModel yourself - see http://slodge.blogspot.co.uk/2013/11 /n42-is-my-viewmodel-visible-can-i-kill.html

+1
source

All Articles