Reputation: 2280
We are considering migrating a UWP app to Xamarin Forms. We need to be able to save the state of complex objects such as an order form when the user navigates away and retrieve that state when the user navigates back. We also need to be able to cancel navigation from a viewmodel.
We use MVVM, so my questions are from that context, but we like to think of ourselves as pragmatic rather than zealous about such things.
In UWP we use the Template10 library to save state in the OnNavigatingFrom event. We retrieve the state in the OnNavigatingTo event. This works even when the app back button is clicked.
Xamarin Forms doesn't seem to have built-in events to handle navigating to and from a viewmodel.
Prism for Xamarin Forms has OnNavigatingTo but does not appear to have OnNavigatingFrom. On some pages we use OnNavigatingFrom to prompt the user to save or discard. OnNavigatingFrom can be cancelled in response to a dialog.
It also appears Prism does not handle navigation using the application back button or the hardware back button. We need to be able to handle navigation to and from viewmodels regardless of how the navigation was initiated.
I've spend a couple of weeks researching these issues and testing scenarios in Xamarin Forms. I assume I have missed something in my ignorance. I understand primitive types can be persisted to application properties, but it would be nice if we didn't have to serialize and deserialize complex hierarchical objects ourselves.
Is there a paradigm/framework in the Xamarin Forms world that will:
I understand there are many questions in this one question, but we are not looking for individual solutions, but a paradigm or framework which gives us the tools to solve them all in Xamarin Forms, such as T10 does for UWP.
Upvotes: 0
Views: 925
Reputation:
Not sure how long you spent researching Prism for Xamarin.Forms, but it provides everything you said it didn't.
You should start with this video. It's a little old, but it will get you started.
https://www.youtube.com/watch?v=DYRLcqG2BAY
As far as actually persisting the data, that's for you to decide. Prism will give you the hooks to do it.
Upvotes: 1