I have this application schema :
[List Page] -> [Detail Page] -> [ShareOnFacebook Page]
^__________________|
Item
in the [List Page]
Share
button if he or she does, the application navigates to a [ShareOneFacebook page]
which displays a Facebook Login Form, posts a message and navigates backIf the user shared on facebook, it will "repost" the message, because the application store the session so it will navigate back to ShareOnFacebook, and then back to my Detail page.
If the user didn't share, he goes back to the List Page.
How can I "ommit" the ShareOnFacebook page in my navigation stack ?
Try this: Call NavigationService.RemoveBackEntry();
in the OnNavigatedTo
method. This will remove the previous page from the stack. In my opinion the trick with Navigation.GoBack();
is not satisfying because it shows the page to remove for a short time.
Note: Works only with Windows Phone OS 7.1 (Mango) SDK
I have a similar situation in my app, i solve it with a very simple solution.
If you want to "skip" a page in your backstack, place some logic in the NavigatedTo() function of that page.
For example: you can have a bool that you set to true when you post to facebook, and then place the following code in the NavigatedTo() function of the ShareOnFacebook page.
Here is pseudo code:
if (alreadyPosted)
Navigation.GoBack();
The GoBack() function will skip this page and return to the previous one, the user will never see the page.
Have a look at simple library i wrote for such purposes: http://navcoerce.codeplex.com/
var fluent = new FluentNavigation(RootFrame);
fluent.WhenNavigatedTo<MainPage>()
.ThenTo<LoginPage>()
.ThenToAnyPage()
.RemoveEntriesFromBackStack(1);
fluent.WhenNavigatedTo<MainPage>()
.ThenTo<LoginPage>()
.ThenTo<RegisterPage>()
.ThenTo<PaymentPage>()
.RemoveEntriesFromBackStackTill<MainPage>();
fluent.WhenNavigatedTo<MainPage>()
.ThenTo<SecondPage>()
.ThenTo<RegisterPage>()
.ThenOptionallyTo<ForgotPasswordPage>()
.ThenToAnyPage()
.RemoveEntriesFromBackStackTill<MainPage>();
fluent.WhenNavigatingTo<PaymentPage>()
.RedirectTo<LoginPage>();
fluent.WhenNavigatingTo<PaymentPage>()
.If(() => false)
.RedirectWithReturnUri<LoginPage>("ReturnUri");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With