Correct place for initialization of data in Prism INavigationAware viewmodel

In Prism navigation aware projects I have been using the pattern of initializing my data structures for views in the OnNavigatedTo method, along the lines of:

public override void OnNavigatedTo(NavigationParameters parameters)
{
if (SomeCollection == null)
SomeCollection = new ObservableCollection(await dataService.GetItems());
}

The newer versions of Prism now introduce the OnNavigatingTo method and people seem to be advocating using this for the loading of data to avoid the issue of the page being shown before the data is loaded. However I've seen references to this method not being called when navigation is initiated from the hardware or software back button. If that is the case would putting the data initialization code into OnNavigatingTo not be a very bad idea as the page could potentialy be loaded without the data structures being initialized?

I'm wondering is there a 'prefered' pattern for data initialization and loading within the new Prism navigation structure?

Tagged:
Sign In or Register to comment.