Reputation: 1
I am developing one application, in that I have 3 pages. In first page I have List Box with some data and in 3rd page I have application bar for navigating to first page. I will get the list box data from the server. Whenever I am binding the List Box with server data, it is rendering properly but if the user navigate from 3rd page to 1st page using application bar then List box is not updating with fresh data, it is still displaying old data. If user comes to first page using back key press then new data is rendering.
I am using observable collection to bind List Box data and used NavigationService.Naviagte() for navigation.
Help me to resolve this issue. Thanks in advance.
Upvotes: 0
Views: 43
Reputation: 2771
As I understand everything is fine when you start. But the update is not happening upon second return, i.e. Through navigation.
My thought is that all your code to do this is in the constructor, and since the page is not removed from memory the constructor will not be called.
Two solutions move the code to a loaded event. Simply in the constructor write this.loaded += eventname;
Or you could put code in the onnavigatedto event. Write as a new function protected override onnavigatedto.
Putting it in the navigatedto, would probably make your app less responsive if you do server calls. If you have the code in the loaded event then the information will be uploaded when it is done. Which means the user will have a moment with old information. You could then introduce a waiting screen if it is an issue.
Upvotes: 0
Reputation: 837
I am not very sure about your problem because you haven't cleared the whole context. But assuming that your data is refreshing on back key press, I can suggest you use NavigationService.GoBack()
instead of NavigationService.Naviagte()
. The former method call is equivalent to back key press. NavigationService.Naviagte()
creates another instance of the page in the memory while NavigationService.GoBack()
takes you back to the previous instance. Hope this helps.
Upvotes: 1