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
Related
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.
I have a wizard in my Seam project which has four pages. When user starts the wizard by coming to the first page (wizard1.xhtml) I start a conversation. To do that in my pages.xml I have following code.
<page view-id="/pages/wizard1.xhtml">
<begin-conversation join="true"/>
</page>
At the final page of the wizard (wizard4.xhtml) I have a save button and I end the conversation by using #End annotation.
#End
public String save() {}
However while moving through the wizard, the user can redirect to a page outside the wizard by clicking a link. Note that if this happens the conversation is not yet ended.
What I want is to immediately end the conversation as soon as the user is no longer on a wizard page (wizard1.xhtml,wizard2.xhtml,wizard3.xhtml or wizard4.xhtml). I found this post but a timeout is not a good choise in my case since I want to end the conversation immediately.
I think the most straight forward and natural solution of your problem is to make your click-able link like this:
<s:link value="here is the link" view="/expectedView.xhtml"
action ="#{targetBean.endingConversation()}"/>
And your endingConversation() method can be like this:
#End
public void endingConversation(){
//do cleanup code
}
The idea is simple, you should employ a guard in every possible exiting points.
Not sure if it will work, just a thought.
Create some javascript function using a4j:jsFunction that calls a method that's annotated with #End.
You then add this jsFunction as an onClick handler to all Your links. (Not sure if onClick is the best handler though).
When the user navigates away from Your wizard the method is called and the conversation should be ended.
If you are using pages.xml (or the per-page page.xml files) to implement page navigation in your application, then you have to specify redirect behavior, for each page, based on the action string. In the navigation rule for each redirect that is not continuing your wizard conversation, you can add <end-conversation />. This is similar to other suggestions, but the result would be navigation rules files which illustrate your applications page flow including the demarcation of your long-running conversations.
In my apllication there are two from.The default form that is the MainPage.xaml and another form called login.xaml.
I have a button on MainPage.xaml,and my requirement is when the user click that button the Login page should be navigated.
This is my first experience in silverlight can i get that easily understandable code.
this.NavigationService.Navigate(new Uri("/Pagename", UriKind.RelativeOrAbsolute));
In this give your xaml or aspx (/Pagename) only no need to mention .xaml or .aspx
Instead of navigating, you could use a Childwindow
Otherwise, I think, you would have to use the Silverlight navigation framework, but this is quite complex. I'd suggest you to first have a child window pop up if you want to do something!
On Button Event
this.Content=new Login();
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.
What is the best way to make password/logon screen? Iread somewhere that it is better to use a popup control. If so where exactly do I need to create it, in App.xaml?
There are number of things you need to consider while implementing a login screen for your Windows Phone 7 application. Here is a sample that can give you an idea of how to get started, if you haven't. One of the important aspects of a login screen is its appearance on the "back stack" - the list that grows while you are within your application, each item in this list is accessible through the "back" button. Ideally, you wouldn't want the user to press the back button and view the login screen. In other words, the login screen should never be in the "back stack". Therefore, it is probably best to implement the login screen as popup, see Peter Torr's post discussing this.
Peter Torr published an article on "Places" which could help you design your application with the login screen.
Regarding implementation of a popup, I posted a simple example in the Answer linked below which you can check out. In this case it implements a context menu.. you can populate the popup with whichever contents make sense for your login screen.
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/e6d2a444-91d9-4d69-937e-689b24c36c09
I recommend reading the two links Indyfromoz has hooked you up with for how to handle a login screen wrt the navigation service. This are the most relevant and the current posts on the topic of handling login screens and the like wrt the navigation service.