I have 2 pages in my Windows Phone 8 XAML app, "MainPage" and "Play".
I NavigateTo Play from MainPage, then hit the back button to return to MainPage.
Once I NavigateTo Play again, 2 things happen that I find confusing:
My constructor for Play is called again, yet the controls on the page still contain data from the last page visit.
Even though I see data in page members the data does not render on the screen.
There's something basic here I'm missing? How do I either get a completely new page; or re-render the previous instance?
Thanks
-John
You can use different class to hold your data, I think that is the problem. You can see this for more info.
Related
I want to enable caching for a page that loads when an ListView item is clicked. So when the user clicks a second time on the same item, the app will navigate to the previous cached page.
(I'm using LayoutAwarePages and I suspect that this should be possible if in the OnNavigatedTo method the NavigationMode parameter is different from NavigationMode.New)
Any ideas?
You affect the page caching by setting the NavigationCacheMode property of the page in its constructor. By default it is disabled, but if you enable it, you'll get the existing page instance every time you navigate to it. This means that even if the user navigates to a different item in your ListView, the same instance of the page will be reused.
I've found a library reimplementing the navigation framework to make it more like the one in Windows Phone, i.e.:
When navigating back the cached page is used.
When navigating forward a new instance of the page is created.
If I understand your question correctly, you require a different caching behavior from both of the above. To achieve that you could either base your alternative navigation framework on the one in the library I linked to or simulate the behavior by persisting just the page state for each item instead of actually caching the pages.
in my Windows 8 (Modern UI) App, i want to add a GroupedItemsPage. When I add it as my
main Page, everything Shows up, and the sample data of the template is displayed.
But when i want to add it as an additional page, that i navigate to through my MainPage,
the Content is not displayed. I only see the Title but now Elements at all.
Can anyone help me with this?
Can you provide some sample code? You might have mixed something up with the Databinding or the navigation.
I have a DropDownChoice with a PropertyModel in my page and I have some other actions which take me to different pages. Now when I click on the Back Arrow on my browser, I come to my page which has the DropDownChoice with the previously selected choice. I understand PropertyModel holds the value for me. But how can I get rid of it when I hit Back button and why is the onBeforeRender(both on the class as well the Component) not working when I hit the Back button. Please comment if my explanation is not clear enough. I am using Wicket 1.4.8
onBeforeRender doesn't work because it's never called. When you navigating using "Back" button, no new request are sended to your server, hence page rendering never occurs. The only way to solve your problem - is to use javascript.
I have an application where from the MainPage.xaml I navigate to a page called say two.xaml.
In Two.xaml I then navigate to Three.xaml..
Now for Three.xaml I want to navigate back to the mainPage.Xaml.
In Three.xaml if I do
this.NavigationService.GoBack();
this.NavigationService.GoBack();
I get an InvalidOperationException.
If I do
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
the system will crate another instance of MainPage.xaml, which I do not want as it will lose its original state.
Anyone have solutions to this issue?
you can save the actual state for example in the State-Property of the PhoneApplicationService Class, then Navigate through your pages and when getting back to the MainPage you just implement the OnNavigatedTo()-method of the MainPage and load the State-Data.
Hope this helps...
AFAIK, you are not supposed to manipulating the back stack in your app.
What cordellcp3 says may be a good idea to implement
If your intent is to navigate in this way:
MainPage->PageTwo->PageThree
User presses Back Button and goes to MainPage you can use this:
NavigationService.RemoveBackEntry()
documentation
hope it helps
Here is the brief detail of issue.
I have Page1 where I have put LinkButton. The LinkButton Has property PostBackUrl pointing to Page2.
When user is redirected to page2, I am using Page Load method to access controls from previous page & get the needed value. To make clear, I am using this approach becuase I cant use querystring.
Page 2 has 2 web parts on it. The web parts use data received in Page Load event from page1 and renders data.
This works perfect on first page load. When user clicks on a URL in page which posts back, the web parts gets lost.
Note that if I come directly to page2 without going at page1, then web parts are retained in the page and they are not lost.
Can anyone give me the clue of issue cause?
Thanks in advance.
Do you have any debugging enabled? you are most likely looking for values on page load that don't exist and might be getting exceptions that aren't handled properly.
I am not sure why but somehow code was throwing an exception when I tried to access the property Page.PreviousPage. Though I had made sure to check null on each step. Even code was never get hit when web part was lost. So it is still a mystery for me.
Just in case someone comes across this issue my workaround may help. I used Post back to page2 using post method. I accessed the variables using Page.Form[] variables. This way my issue of getting web parts lost got resolved.