Suggestion... persistent viewmodel instances

Oct 19, 2014 at 3:19 PM
Edited Oct 19, 2014 at 3:21 PM
Any chance you can extend the IoC to persist the viewmodel instances?

I would like to be able to navigate to a new page in a single-page navigation app based on a selection from a ListView. Currently, on the itemInvoked event I am retrieving the item via the index (eventObject.detail.itemIndex) and setting it to a public property in the viewmodel.
I then do the navigation and the new page's script retrieves the previous viewmodel and sets the dataContext now to viewModel.selectedItem.

However, the ViewModelFactory just creates new instances at the moment...

I suppose I could take a look at how MVVM-Light does it and try to rig up something that works...
Oct 20, 2014 at 6:39 PM
Hi Lee,
thanks for the feedback, much appreciated.

I've modified the current implementation of ViewModelFactory in order to initialise ViewModels and keep their instances alive.

I'm also planning to integrate it with the new IoC for the future to avoid the definition of all singletons in the ViewModelFactory and better integration with Navigation / application lifecycle.

Hope this helps,
Marked as answer by leemcpherson on 10/20/2014 at 7:29 PM
Oct 21, 2014 at 2:29 AM
Thanks for the quick turn-around, this is excellent. :)