1

Can I somehow easily replace current viewmodel with another using mvvmCross?

When I use ShowViewModel the current view stays on back button stack. Combination of Close(this) and ShowViewModel doesn't seem to work.

Is there any easy to launch another viewmodel so that back button from that view will get you to previous view and not to the your current view?

elevener
  • 1,097
  • 7
  • 20

1 Answers1

1

You can generally do this sort of thing by writing a custom presenter on each platform you are targeting.

This isn't perfect - because the platforms don't all present the same capabilities - but you can normally find a way for your app to do what it wants to do.

For example:

  • in WindowsPhone, you can change your presenter's Show method so that it calls RemoveBackEntry before calling the Navigate
  • in iOS, you can change your presenter's Show so that it manipulates the UINavigationController's ViewControllers array (the C# equivalent to How to remove a specific view controller from uinavigationcontroller stack?).
  • in Android, you generally have to resort to tricks like using NoHistory=true

For more on custom presenters (which are essentially custom navigation services), see https://github.com/MvvmCross/MvvmCross/wiki/Customising-using-App-and-Setup#custom-presenters and the links on http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html

Community
  • 1
  • 1
Stuart
  • 66,722
  • 7
  • 114
  • 165
  • Thanks. I believe that's a standard task and it makes sense to implement that in basic libraries when you have time if it's possible. – elevener Jan 18 '14 at 16:12