Jimmyt1988
Jimmyt1988

Reputation: 21126

How do i navigate backward and refresh the page i have navigated to?

I am using App.RootFrame.GoBack(); but it does not refresh the page (which makes sense).

I would like to enforce a page refresh... Anyway of doing this?

Upvotes: 0

Views: 153

Answers (3)

JayDev
JayDev

Reputation: 1360

on a 'GoBack()' the OnNavigatedTo() method will be run, but the constructor for the page won't be. Therefore you need to refresh the page yourself in the OnNavigatedTo() method.

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // Refresh the data in here
}

Also I would suspect that you would be better of using the navigationservice to go back i.e:

NavigationService.GoBack();

Upvotes: 0

m.casey
m.casey

Reputation: 2599

Possible duplicate of this.

In any event, you probably want to use the NavigationService as follows:

if(NavigationService.CanGoBack())
{
    NavigationService.GoBack();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // ensure view has the data it needs
}

Upvotes: 1

Jimmyt1988
Jimmyt1988

Reputation: 21126

This seemed to do the job well.

IEnumerable<JournalEntry> pages = App.RootFrame.BackStack;
string pageURL = pages.First().Source.OriginalString;
App.RootFrame.Navigate(new Uri(pageURL + "?Refresh=true&random=" + Guid.NewGuid(), UriKind.RelativeOrAbsolute));

Upvotes: 0

Related Questions