WP7, determining which page I switched from

I have 3 pages. Page 1 is the search criteria, page 2 is the list, page 3 is the details.

If I go to page 2 from page 1, I want to call a web service and upload the data to the page.

If I go to page 2 from page 3 (that is, using the "Back" button), I do not 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 don’t see anything in the navigation event that tells me about it.

Any ideas?

Greetings

Steve

0
source share
3 answers

As a new (& better?) Solution, you should consider using a new (on 12/9/2010) Non-linear navigation service .

+1
source

There is no way to do this with the API / SDK as is.

However, you can tell the calling page page 3 what this is called.
One example of how to do this would be to include an entry in the query string. i.e.

NavigationService.NavigateTo(new Uri("page3.xaml?from=page2", UriKind.Relative)); 

Then on page 3:

 string sourcePage; if (NavigationContext.QueryString.TryGetValue("from", out sourcePage)) { // test the value of sourcePage and act accordingly } 
+1
source

Alternatively, you can add a new entry to the application resource dictionary and retrieve it on the next page by overriding the OnNavigatedTo method.

To add an entry:

 App.Current.Resources.Add("from",2); 

To get a record:

 if(App.Current.Resources.Contains("from") { lastPage = (int)App.Current.Resources["from"]; } 

For more information, see Chapter 6 of Charles Petzold's book at the following link:
http://www.charlespetzold.com/phone/

+1
source

Source: https://habr.com/ru/post/1344681/


All Articles