I'm developing a Windows Phone application and I have three screens:
Main screen
Login selection screen.
Sign in screen.
When user has signed in and push "sign in" button I want to come back from screen 3 to screen 1.
Now I come back to screen 2 and immediately to first one. I don't want to show 2 screen.
Is it possible to do this?
Try this
Assume your pages are named as FirstPage.xaml, SecondPage.xaml, ThirdPage.xaml
//Check for the first page and remove the remaining back stack in your ThirdPage.xaml
while(!NavigationService.BackStack.First().Source.OriginalString.Contains("FirstPage"))
{
NavigationService.RemoveBackEntry();
}
NavigationService.GoBack();
Somewhere in page 3 add
NavigationService.RemoveBackEntry();
This will remove page 2 from the back stack. Now when the user hits the back key, he'll navigate directly backwards to page 1.
But as Amal Dev noted, Microsoft wants you to let the user navigate to the previous page. This rule doesn't seem to be enforced too much, it's probably meant as "never ever confuse the user". If you confuse the certificating tester, your app will fail certification.
You can use the NavigationService.Navigate method for this.
NavigationService.Navigate(new Uri( string.Format("/your page name.xaml?val={0}", ValueTextBox.Text), UriKind.Relative));
Please refer the link given below.
Simple Navigation In Windows Phone 7
Related
In Xamarin app, I have a page after scan a QR Code. An AlertPage to show if the ticket is good or not (I don't want a DisplayAlert). On this page I want a button to return to the page before the scanner, and an other button to return to scanner.
If you want I have 3 pages:
ListPeoplePage (with a button to go to scan who create new ZXingScannerPage);
ScannerPage (when you scan you go to AlertPage);
AlertScanPage (with backbutton to go to Scanner and an other to go to ListPeoplePage).
I'm not sure if it's possible and I have problems with my NavigationStack (I have never the good number of pages).
If you know a good method to add this AlertScanPage it would help me.
My question is to go from AlertScanPage to ScannerPage.
i have two asp page,first one is home and second one is test. In home page user can select the type of test they want to take up, and after pressing start button a new window is open for taking the test. What i want to achieve is , after completing the test i want to close the test window and redirect to another page, and this redirect should hit the previously opened home window.
You don't clarify that you have popup window or blank window i am aspecting for the popup
In submit click button press
String x = "<script type='text/javascript'>window.opener.location.href='**Your new url of new page after completing test**';self.close();</script>";
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);
From self close you will be able to close current window and by window.opener.location.href you will able to redirect to new url
I hope this will help you
regards....:)
Yes you can do these 2 ways:
Window.Open() /.showmodalDialog() and keep parent and child open as well, or
On the home page click on your start button. Use code Response.Redirect("~/Test.aspx"); assuming it resides with Home.aspx. Take your test using ASp.Net wizard control or hiddens divs what ever suits you easy. Manipulate data on test page , save and get result to and from database using SqlConnection and SqlCommand assuming you have Sql Server as backend. Hold the table or any value in either cache or Session and throw it on your home page. Do whatever you want.
This will be not possible. What you can do is to redirect the user to the home page after completing the test, but this will be in the same windows.
I am trying to build a online exam project. Once the student login the exam page will be in fullscreen mode. I want to know if the student presses any shortcut keys like Alt+Ctr+Del or Alt+D etc. which ever it may be. I just want to know is it possible to find out if the current page is out of focus ? So that I can end the session at that time.
Please help me with this.
if(string.Compare(Request.Url.LocalPath,"MyPage.aspx")==0)
// maek your session Null whatever you want
}
This can be done in master page easily
In my WP8 app, i have situation where i have to navigate from one page to another and afterwards i need to reload the same page for some reasons.
MainPage.xaml --> Page1.xaml --> Page1.xaml --> Page1.xaml
When user press the backkey should go back to "MainPage.xaml" page.
I tried using the NavigationService.navigate() for navigation, some reason i couldn't able to reload the page. If i pass any unique query strings (eg: Guid) with navigation url, i am able to reload the page. But, when i press back button - it never goes back to Mainpage.xaml page.
Is there any best way to achieve this?
Pass in a query string every time you reload the page (such as your random GUID). On your OnNavigatedTo method check if the GUID query string exists. If it does exist, you know that you don't want this page on the Navigation Stack because it's the reloaded version, so you can remove it by calling NavigationService.RemoveBackEntry.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
string guid = string.Empty;
if (NavigationContext.QueryString.TryGetValue("guid", out guid))
{
//guid exists therefore it's a reload, so delete the last entry
//from the navigation stack
if(NavigationService.CanGoBack)
NavigationService.RemoveBackEntry();
}
}
Use NavigationService.RemoveBackEntry method to remove last navigation stack entry.
You can also remove all elements from navigation history:
while(service.CanGoBack)
service.RemoveBackEntry();
and then add the one you're interested in.
NavigationService.Navigate(new Uri("/MainPage.xaml?" + DateTime.Now.Ticks, UriKind.Relative));
You can use it under a control to navigate to same page
Because I couldn't find any Windows 10 (Universal apps UWP UAP) questions about this, and this one seems to be top result on google search to reload a page, here is a solution:
NavigationService.Refresh();
I'm using Template 10 on my app, so I don't know if it matters here. The lib encapsulates NavigationService on its own INavigationService
Well it's my first question here and as far as i searched i didn't find a solution for my problem. I am coding my first rssreader app for WP7 and i am facing a problem with the page state. I have 3 pages and navigation goes like that
mainpage >>> listitemspage >>> detailspage. Mainpage is a databound model with preconfigured feeds category items (urls and names), listitempage is a page in which i implemented a webclient to read feed items and detailspage is where i pass the details of the selected feed item from listitempage. Page state working in these situations:
mainpage >>> start button >>> back button (OK)<br/>
listitempage >>> start button >>> back button (Doesn't work)<br/>
detailspage >>> start button >>> back button (OK)<br/>
In detailspage i save the page state using OnNavigatedTo/From and State.TryGetValue
This seems to work but if i create a button with a browser task so the user can navigate to the full article when the browser open and user press back button the details page state works. If the user press for second time the back button then the app is exiting instead of navigating back to the listitempage. So i have this problem too:
detailspage >>> browserbuttontask >>> backbutton >>> restorepage >>> backbutton->exit<br/>
Any ideas?
I'd recommend using the Tombstone helper on codeplex written by Matt Lacey (of the Windows Phone User Group).
http://tombstonehelper.codeplex.com/
It will either solve all your problems very easily or at the very least show you how to write your page states off to isolated storage for long term use (remember the state cache only survives while the device is powered and so long as the phone doesn't need to clear it's memory)
Hope this helps
Rgds
Simon
If you want to save page state without messing with IsolatedStorage try SterlingDB. It uses IsolatedStorage but it is very simple to setup and use. You can add sterling via nuget. You will have to stick data you want persisted in a class but saving and loading is simple.
Beyond that you also might want to look at Caliburn Micro. It adds page lifecycle to your ViewModels like OnInitialize, OnActivate, OnDeactivate. It also adds some nice stuff for WP7 like automagically persisting properties on a ViewModel to IsolatedStorage or phone state.
http://www.sterlingdatabase.com/
It sounds like your application is throwing an exception when restoring state to your list page, which has the effect of terminating the application.
Have you tried doing all this with the debugger attached? It should show you what exception is being thrown and where.