Non Linear Navigation Service - windows-phone-7

I'm creating an app that has start button which brings you to start page from anywhere in app.
However back navigation stack hurts when I just navigate to start page.
Looking for solution I found NonLinearNavigationService. The trouble is that download links are target to app hub, which (now, as we have new better app hub) redirects me to main page and nowhere further. Also I failed to find it on app hub using build in search engine.
Anyone knows where from can I get it?
Or maybe another solution for navigation loops?

If you use RemoveBackEntry(), the entries are programmatically cleared from the backstack so you don't have to deal with the side effects of actually navigating back through the pages to pop them off the stack.
The NonLinear Navigation Service effectively does what you have tried. It calls GoBack() to traverse back up the stack. What it additionally does to prevent the flicker is to make the root frame transparent. See this question:
Skip a page when the back button is pressed, WP7
I don't want to call your question a duplicate because I think before Mango came out, that was probably the solution that needed to be used. Now that RemoveBackEntry() has been added to NavigationService, I think using that would probably be the better approach.

No linear navigation in WP7 is generally not recommended, because of the hardware back button and the UX on the rest of the phone, so you should probably structure your app to avoid this. However it should pass the certification process.
Here's another similar question In-App Home Button to Navigate to MainPage allowed? and an article about circular navigation which mentions the NonLinearNavigationService you are talking about http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/12/13/solving-circular-navigation-in-windows-phone-silverlight-applications.aspx.

If the only non-linear part of the navigation is the home button, you could use NavigationService.RemoveBackEntry() in a loop untill it raises an InvalidOperationException in the home button event. When the InvalidOperationException is raised the BackStack is empty and the next click on the back button exits the application.

Related

WP7: Is it possible to intercept the backstack before the journal thumbnail is created/stored

You all know the Windows Phone backstack right. If you go through some apps, tap the Home key after starting each app. Now tap and hold the Backkey to see the Backstack. You can now see some small images of your apps, and can pick which one to go to right.
Question:
Is it possible to intercept before the backstack image is created? I have tried to blur my page in various events (include OnNavigatingFrom) to no avail.
My guess is some other event (probably something we don't have access to) is triggered and a bitmap is created, because when you use the Backstack to navigate you can just see a slight transition from the saved image to a real page IMO.
Does anyone know if its possible to intercept or manipulate these images on the backstack?
Example screenshot from WP emulator of the Backstack thumbnails
Following my comment, I've just tried this:
Set a breakpoint anywhere in the code
Start the app with the debugger attached, then let it reach the breakpoint
While the execution is stopped by the debugger, long press on the back button
The task switching UI is displayed even though the managed code execution is stopped
From there, I think we can safely conclude that the task switching and the thumbnail are handled entirely by native code. Therefore, there's nothing you can do.
I recently wrote a blogpost in which I discuss the ways I tried to hide data from the application snapshot. (You can read it here: http://corstianboerman.com/trying-to-hide-crucial-data-from-an-application-snapshot/)
The outcome: You just can't hide it.

How Can I navigate back to home screen in Windows Phone 7.1

I have a created an app which has a Homescreen/landing page,Now whenever user navigates till last page and clicks the device back button he is redirected back to Homescreen. Now the issue is I have written code to clear all the backstack whenever user lands on the Homescreen in Homescreen OnNavigatedTo block. So whenever user clicks device back button of last page he is navigated to homescreen by creating a new instance of HomeScreen page.
On Homescreen the backstack is cleared, so the user can exit the app from homescreen when he clicks the device back button.
But according to Microsoft marketplace policy, backbutton must go back or go to previous page in backstack and not navigate to new page.
So the question here is should I clear all my backstack and go to homescreen or what I am doing is right?
As far as I know, they are not so strict as that. They just want you to handle the back button.
I had blocked the back button in some pages of my application and the certification failed. I changed the behavior of the application, to either close the application when navigating back or jump a couple of pages back, and it passed certification.
Just make sure the back button does something...
The reason they dis-advise you from doing this is because you are using the wrong organisation.
Going deeper usually means you get too more specific data, in a way you can go back up one page.
Going to the side usually means that you get more data, eg. Panorama / Pivot
I can't see a case where going deeper would disallow the user from going back to pages in between, I would not use your application if I had to start it every time again or when it would go deeper when it is actually supposed to let me scroll through the content.
Trying to surround their certification is definitely not the way you should be going, but rather embrace it.
See this page for layout tips and tricks for the Panorama and Pivot controls.
As per the comments, you might find it a lot easier to ditch having to learn all platforms.
A jQuery Mobile application can do that for you.
jQuery mobile framework takes the "write less, do more" mantra to the next level: Instead of writing unique apps for each mobile device or OS, the jQuery mobile framework allows you to design a single highly-branded web site or application that will work on all popular smartphone, tablet, and desktop platforms.

Implementing shake to go home Functionality

In my application client had a requirement that. When the user shakes the phone he/she should navigate in to the home page. So writing the shake event handler in each page seems bit difficult. Is there any way present to handle this event in a single page like app.xaml, if any one go through similar situation and found a solution please help me too for achieving the functionality
For shake detection you should use accelerometer like described in this article. For presenting it to all pages, you could use
RootFrame
property in your app.xaml.cs and call it's Navigate property when the shake is detected.

How to handle first run and splashes in WP7

I have spent a bit of time rummaging through Stack Overflow to find out how to deterministically close an application based on an action. Most if not all answers say you can't or shouldn't do it. If this is so I would like to phrase my question differently and see how people are handling two issues I am having trouble with.
Just to let you guys know I am using Caliburn.Micro for this project.
Ok so the flow of my app can be broken down into two parts, the initial flow and the standard flow, these are as follows
Splash -> Welcome -> CreateAccount -> MainHub (all other functionality branches from here)
Splash -> MainHub (all other functionality branches from here)
Based on this flow, the feedback from my better (beta) testers is that they expect to exit the app on pressing the back button on the hub, which they see as the entry point. Currently as per navigation they go all the way back to the splash.
I see other apps have this functionality, but without forcing the application to close (Which I read is a no no) how are they achieving this desired functionality.
NOTE: I do not want to put in an exit button as I believe it goes against the natural flow of a WP7 application.
First of all, you cannot add a exit button. The only way to exit a application is to crash it, which will not be approved for marketplace certification.
As for your problem, you simply have to remove views from the navigation stack upon completion of a known navigation.
For this, use NavigationService.RemoveBackEntry.
You can access the NavigationService from anywhere, using this snippet:
(App.Current.RootVisual as PhoneApplicationFrame).RemoveBackEntry()
Regarding EULA / Login screens (and Splash) - don't make them into pages. If you instead make them Popup or Dialog 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.
Source: http://blogs.msdn.com/b/ptorr/archive/2010/08/01/exiting-a-windows-phone-application.aspx

Navigation & Tombstoning - Best Practices

I'm just learning about how to navigate between pages and tombstoning. I'm wondering if anyone can point me to some good examples that not only show me the basics of how to use Navigation properly but also good examples of more complicated and advanced navigation issues?
Some questions I have revolve around memory leaks when navigating to other pages and navigating back?
Is there a close page call, once the page has done its job (I don't want an instance of it hanging around after I'm done with it)?
Another question is how to I maintain state if the app gets tombstoned (still trying to wrap my head around that term).
Thanks!
There's no close page call, the OS automatically closes pages when they're backed out and releases used memory (so there should be no leaks here).
Some resources here that cover tombstoning and advanced navigation concepts.
Understanding the Windows Phone Application Execution Model, Tombstoning, Launcher and Choosers, and Few More Things That Are on the Way – Part 1, Part 2, Part 3
Introducing the concept of “Places” - Peter Torr's Blog
Redirecting an initial navigation - Peter Torr's Blog
I like thinking about WP7 navigation like a simple browser that only have back button. The Naviation model is based on stack pattern (Last In First Out), need to get through all to get back to first page. This is not what PC user are used to but in mobile world is one of the best solution.
You have to stick to this model and never ever do "go to home page" button - your app will not pass the certification for sure(there are some workaround with excetions but I wouldnt recommend that).
A lot of pages can get the user pissed that's why a good idea is to have 3 to 5 pages max. For instance, first page user picks what he is going to do, next page is login page and then for more complex interface use panorama and pivot control.
To the simple browser model add cookies. When your browser load a page it sets a cookie with some information, next you close the browser and when you go back to the page it can get the previous state from that cookie. Tombstoning is very simailar. - link. Some more info about tombstoning
Some questions I have revolve around memory leaks when navigating to other pages and navigating back?
What do you mean by memory leaks? you are working in managed framework.
Is there a close page call, once the page has done its job (I don't want an instance of it hanging around after I'm done with it)?
you do not have to do this. Page is destroyed everytime you go to the next page unless a thread is still working there.
Another question is how to I maintain state if the app gets tombstoned (still trying to wrap my head around that term).
Basically it's up to develepor to manage this. It is not mandatory but gives a nice user experience.
Another question is how to I maintain state if the app gets tombstoned (still trying to wrap my head around that term).
Use Isolated Storage.
You can have a look into Columbus MVC framework for WP7 source code (http://columbus.codeplex.com/) that I have published recently. Columbus addresses both Navigation and Tombstoning (provides strongly typed navigation with history and View Models that can survive tombstoning).

Resources