Am using pages in my application and let me explain simply for your understanding.
I have pages A,B and C.
From page A -> page B,
page A -> page C are possible.
I need to do a action only when the page A is resumed from page B and not from page C.
How can i make it possible, can i be able to send some flag data back to page A from page B’s OnBackPressed. And if so where can i listen to get that flag data in page A.
You can use a QueryString. When navigating from
BtoA, add your QueryString to the URL:Then, in
A'sOnNavigatedTomethod, you can check what the value of thePreviousPageQueryString and react accordingly if its value isb.Update based on comment (will leave the code above for others)
There are a couple of options regarding the
BackKey. Firstly, you can use the code above and then delete that particular page from the history. You can do this by using the RemoveBackEntry method within the code above:You can see more about the Back Stack here.
Alternatively, you could keep track of a global variable, in
App.xaml.csfor example, that is updated whenever a user leaves a page. Then, inA, you can check that variable and see what the previous page was (and reset the variable if need be so that it’s not read again accidentally).