1
votes

In my Windows Phone app, I need to navigate from a page to a new instance of the same page.

How can I achieve this?

If I navigate as follows:-

Page1 -> Page2 -> Page1

It creates a new instance of Page1.

I want to create a new instance as follows:-

page1 -> page1

I tried

NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));

on Page1.xaml - it doesn't navigate.

3
First thought: create Page3.xaml with automatic redirect to Page1.xaml and use it as proxy.MarcinJuraszek
@MarcinJuraszek Thank you, that answered my question.kshitijgandhi

3 Answers

5
votes

Pass a parameter in the page Uri, for example:

NavigationService.Navigate(new Uri(String.Format("/Page1.xaml?id={0}", Guid.NewGuid().ToString()), UriKind.Relative));

Then, if you don't want to keep the previous instances in the navigation stack, you can remove the previous instance calling RemoveBackEntry method of NavigationService:

NavigationService.RemoveBackEntry();
1
votes

If i pass any unique query strings (eg: id) with navigation url, i am able to reload the page as follows -

NavigationService.Navigate(new Uri("/MainPage.xaml?ID="+ a.MyID, UriKind.Relative));
a.MyID++;
1
votes

Very simple. You can achieve it by using below code. Don't forget to mark it as an Answer.

NavigationService.Navigate(new Uri("/Page1.xaml?reload=true", UriKind.Relative));