I was wondering if there is a way to absolutely determine that a view has finished loading or at least that binding has finished it's job. We have a concept of connected views, where changing selection within a picker will clear another picker. This is fine until we want to load our last known state into the pagemodel.
The problem comes when we load our state into the page. We are using FreshMvvm and load the last known state from akavache into the PageModel on Init(). We are clearing the 2nd picker by listening to SelectedIndexChanged on the first picker. The issue is, loading the data fires SelectedIndexChanged which then clears a value. So loading something loses data which is not ideal.
Ideally we are able to load the data into the view model before databinding starts doing its thing.
I've attempted to setup the SelectedIndexChanged event to command with a CanExecute predicate setting an IsInitialised flag to true after the data has been set on the page model within Init(). However this is unreliable, and we end up with a race condition between loading data, binding finishing and the event firing and being handled.
I'm working on sample code to display the problem, but in the meantime wanted to see if anyone had come across similar issues and how you went about solving them.
In the absence of a PageLoaded or similar event an idea I had was creating a platform specific dependency which knows about each platform's view loaded events and sends that through to our pagemodels, but I feel that might be over-complicating something that could be done in other ways.
Surely someone else out there has had to tackle similar issues, look forward to any input you guys and girls can provide!!