I have 3 pages. Page 1 is search criteria, page 2 is list, page 3 is details.
If I go to page 2 from page 1 I want to call a web service and load details onto the page.
If I go to page 2 from page 3 (ie using the back button) I don’t want to reload the data as I already have it.
To determine what to do when page 2 is activated I need to know where I came from.
I can't see anything in the navigating event that tells me this.
Any ideas?
Cheers
Steve
As a new (& better?) solution, you should consider using the new (at 12/9/2010) Non-Linear Navigation Service.
There is no way to do this with the API/SDK as is.
You could, however, have the calling page tell page3 what called it.
One example of how to do this would be to include an entry on the query string. i.e.
NavigationService.NavigateTo(new Uri("page3.xaml?from=page2", UriKind.Relative));
Then, on page3:
string sourcePage;
if (NavigationContext.QueryString.TryGetValue("from", out sourcePage))
{
// test the value of sourcePage and act accordingly
}
Alternatively, you can add a new entry to application's resource dictionary and retrieve it on the next page by overriding OnNavigatedTo method.
To add entry:
App.Current.Resources.Add("from",2);
To retrieve the entry:
if(App.Current.Resources.Contains("from")
{
lastPage = (int)App.Current.Resources["from"];
}
For more information see Chapter 6 of Charles Petzold book available on the following link:
http://www.charlespetzold.com/phone/