0
votes

I have used the standard navigation service in my app but the problem is

Accounts Page (Show info from datacontext) -> Add Accounts Page

now if i give navigation to Accounts Page from Add Accounts Page it creates new instance of Accounts Page as below

Accounts Page (Old Data) -> Add Accounts Page -> Accounts Page (Updated Data)

when i get to the new instance the data on the page shows the new entry but if get back i get to the add accounts page again & then Accounts Page (Old Data) which does not show the updated entryso i have to get back to the home pag & again navigate to Accounts Page to get it updated so what should i do to make Add Accounts Page save button send me back to the Accounts Page & its updated?

I tried with

NavigationService.GoBack();

NavigationService.RemoveBackEntry();

NavigationService.Navigate(new Uri(string.Format("/Accounts.xaml?Refresh=true"), UriKind.Relative));

but nothing worked as i wanted PLEASE HELP

1
where are you doing your databinding for the view accounts page? if this is being done in the constructor of the page, you will need to move this to the OnNavigatedTo method. This will ensure that the data is bound upon page entry. Define protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e). Don't forget to also call base.OnNavigatedTo(e) in the method.FunksMaName
you are my hero man code was in the constructor...xSHERU

1 Answers

1
votes

NavigationService.GoBack(); is the right way. The problem you need to focus on is: "how to refresh the data when going back to the Accounts Page". The solution depends on your application's architecture. If you used the MVVM pattern, then it's just a matter of adding the new account to the data source in the viewmodel. Otherwise, you should probably reload the account list in the OnNavigatedTo method of your page:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // Load the accounts
}