How to reload a Windows Phone app page without creating a new copy in memory?
In my Windows Phone app, I am trying to reload the app page using the following code:
NavigationService.Navigate(new Uri(string.Format("/Page1.xaml?random={0}", Guid.NewGuid()), UriKind.Relative));
I wrote the code above for the button click event. Page1 reloads fine, but every time I press the button, the app's memory keeps increasing and the app crashes at some time.
Is there any other way to reload or refresh the page without creating a new copy of the page in application memory.
source to share
You can always refresh the page content from code by calling Page.Refresh (); or some similar method, but this may not update all content.
If you decide to do a new navigation (and make sure everything goes back to the original page state), you can remove the previously moved pages from the stack by calling:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (NavigationContext.QueryString.ContainsKey("logedin"))
{
NavigationService.RemoveBackEntry();
}
}
Take a look at the NavigationService class, especially the AddBackEntry and RemoveBackEntry methods:
source to share
try this code
var Frame = Window.Current.Content as Frame;
Frame.Navigate(Frame.Content.GetType());
Frame.GoBack();
Source enter link here
source to share