Frame.Navigate, Frame.GoBack stop working after snap - c#

I'm running into a weird issue where after my app has stopped responding to Frame.Navigate requests after the app has been snapped. I am writing a search app with 3 pages: a query entry page, a results page, and a result detail page.
Running the query successfully uses Frame.Navigate(typeof (Results), QueryBox.Text); to open the results page (Descendant of LayoutAwarePage) in both snapped and unsnapped states.
When the search is run from the unsnapped UI, I am able to click on a result and navigate to the details page. When the search is run from the snapped UI, however, I am unable to actually navigate to the correct page. After the snapped results page has been loaded it appears that any sort of navigation is completely impossible. Clicking the back button does not return to the query page (although it does appear to be affecting the navigation stack, as the back button does go away).
Through debugging, I've uncovered the following information:
The correct button handler code is still being called. Snapped view and full view are executing the same exact code to launch the details page (Frame.Navigate(typeof (DetailPopup), pb.PodOwner);, where DetailPopup is the page, and pb.PodOwner is the data context for the page).
The constructor for the DetailPopup page is actually being called, but the page is still not loading.
After restoring the snapped page to the unsnapped state, the effect of being unable to navigate persists.
After commenting out all changes applied in <VisualState x:Name="Snapped"> of the Results page the problem persists
I've read that there are issues with Frame.Navigate being called from OnNavigatedTo, but all these interactions are happening well after that method has completed. Are there other similar caveats for other methods / events?
If there's any code specifically that you'd like to see I'd be happy to post it, but I'm not sure where the offending issue is and posting the entire page source would be kind of overwhelming ;)

Related

Website hangs only on certain clients ; if ViewState is disabled, loads at normal speed

This is very weird and it has taken lots of time to reach this point.
I have certain clients (from any computer on their network) and on one of my remote-working colleague that when loading some of our sites, the page hangs for 3-4 minutes before displaying.
The same page, on the same client machine, when connected to a wireless network loads fine.
We have checked DNS problems and the DNS resolution works fine.
Inspecting the page load in Firebug, I can see that the ASP.NET page goes into receiving state fairly quickly but then it takes forever to receive.
The head of the HTML file loads, in fact the Firebug's Net tab shows loading CSS, JS files, however the ASP.NET page itself takes, as said 3-4 minutes.
If, while it is loading, I right click and select View Source I see the full HTML content loaded in 1-2 seconds (in Firefox, View Source re-fetches the page from the server)
If while loading in IE, I right click and select View Source (in IE the View source corresponds to what the browser has got available at the moment) I can see that the HTML content is loaded up to halfway through the ViewState, if I keep re-asking for View Source, I can see slightly more of the ViewState loaded.
As a test I have therefore disabled ViewState all together and the page load as fast as it does in our office.
I know that ViewState is and ugly beast, it takes a big chunk of bandwidth and always takes a toll on page load time, however this is not the point.
I do not understand why that affects only certain machine connected to certain networks.
Can anyone shed any light on this?
EDIT:
Re-trying loading the page with ViewState disabled, and now the page load hangs again, further down the HTML content when I view the source in IE.
Interesting is:
When the same page is loaded in HTTS, it loads fine!
FURTHER ADDITION:
The site in question is http://www.theclifftownhouse.com/

Bing maps control hangs the back navigation

I recently ran into weird bug in Bing map control. In short, if the connection is poor and you press the hardware back button on page with map while the map is still loading some tiles, the navigation process hangs up (some times up to 10 or even more seconds). And in case when the time is more than 3 seconds the app will be "a little" not user-friendly and will not meet the technical certification requirements (5.1.3).
To repeat the bug you can create the app with two pages. First one with button to navigate to the second page. And the second page with just map control with high ZoomLevel (more than 14 for example). After the app launches, you navigate to the second page and move map to some unloaded area and then (without waiting for the download to complete) press the hardware back button. And also you somehow must "create poor" connection (in my case, simply disconnecting the device from the computer is enough).
And does anyone have any idea why this occurs and how to workaround it?
EDIT: The same bug can be observed in the Foursquare application for wp7 - if you go to the page where the place is shown on the map in full screen, then slide the map into an unloaded region and press the hardware button back.
It seems that the problem is in the Bing Map Control.
Hide the Maps control using the Visibility first, before you navigate out of the page. That way the control will become inactive and memory consumption of the page will decrease, thus allowing to switch pages faster.

How to remove backstack pages to exit application

I have an application which displays a disclaimer page when it is first run. Once you select Accept or Deny you never see the page again.
However, when you press the back key attempting to close the application after the first run, you go back to the disclaimer page, then if you hit it again, back to the main page and then again to exit.
This only happens the first time the application is run, but I would like to have the application ignore the disclaimer page when the back key is pressed and exit the application.
Other than forcing an unhandled exception error to close the app, are there any other options?
Thanks in advance.
Solution: Add the below NavigationService.RemoveBackEntry(); in my main page.
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
{
NavigationService.RemoveBackEntry();
NavigationService.RemoveBackEntry();
}
I am sure there is a more elegant way to do it, but I was in a hurry, so I implemented it in a following way.
I have a static global enum that stores the last page I was on. Assuming you have pages called pgDisclaimer and pgMain.
In the OnNavigatedTo event of the pgDisclaimer page, check to see where the control came from. If it came from pgMain, just execute NavigationService.GoBack() and you'll be out of the application and the user will never actually see pgDisclaimer page (not even a flicker).
Edit: Found the more elegant way. In Mango, you can use the horribly named NavigationService.RemoveBackEntry() method.
You should display the Disclaimer as a popup rather than a page, that way you don't have to worry about navigation and backstack issues. I saw this mentioned in a Channel 9 video:
Windows Phone: building apps that customers love, end to end
The specific part in the presentation that covers this is at around 26:20. He's discussing a login page that prevents a user from navigating back out of the app, but the concept is similar.
Also, from this MSDN Blog Post:
I forgot the #1 piece of advice regarding EULA / Login screens - don't make them into pages. If you instead make them Popup controls you can show or hide them at any time (on first navigation; when the user hits a "protected" part of the app; after a time-out; etc.) and they don't consume a slot in the backstack. This should cover the majority of cases.

Clear Navigationservice Buffer - Or Reset App? (Windows Phone 7)

I have an app I'm working on where the user gets navigated two pages deep, meaning:
Select stuff, click next -> select stuff, click next -> results
On the results page, I'm doing a Navigationservice.Navigate() back to MainPage.xaml but now the user has the ability to hit the back button which can break some things in the app. How can I clear that buffer of pages available? Any way to for Navigationservice.canGoBack return false even if it's true? If the buffer can't be cleared, the is there a method which will restart the app to get the user back to the MainPage.xaml without having any navigation history?
Thank you,
Nick
Here's a few references for solutions to clearing the back stack.
Want to "reset" an app but how to deal with backstack pages?
Removing a page from the navigation stack
Can the navigation history be cleared
Alternatively, consider Peter Torr's suggestions on handling navigation scenarios.
Introducing the concept of “Places”
Redirecting an initial navigation

delay loading of a silverlight page

How would i go about delaying the total load of a SilverLight Page? I take a parameter out of the querystring on the page load of a Silverlight web page, and then send it to a web service boolean function to process. The result of the return value is used to determine whether to fully load and display the page, or direct to another page. The system works pretty much fine, however when the result from the web service returns, even if it is decided that i need to navigate away to another page, it still displays the initial page for a very short time. How can I stop this brief showing of the initial page?
Take a look at this article: http://www.codeproject.com/KB/webservices/CodeOptimizationTechnique.aspx
The point is that you must not do anything until you receive the data back from the webserice. When you receive it only when you can send the user to the right side, and remember also to consider that maybe you do not get a response from the server sometimes.

Categories