Reputation: 1532
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.
Upvotes: 1
Views: 3979
Reputation: 1677
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));
Upvotes: 1
Reputation: 1532
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++;
Upvotes: 1
Reputation: 6424
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();
Upvotes: 5