Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Navigating and Passing Data between XAML Pages - Day 3 - Part 3

Download

Right click “Save as…”

Most applications—even simple ones—will require at least two or more Silverlight pages. This video demonstrates how to navigate from one Silverlight page to another, as well as how to pass information between two pages using QueryStrings. Finally, Bob explains how to use the phoneAppService.State[] to save important values in case the user wants to navigate back to a page and expects to see the data and control property settings as they were previously set.

Download the source code in c#

Download the source code in VB.Net

Follow the Discussion

  • SvenSven

    /appname;component/foldername/pagename doesn't work for me to navigate between pages.
    What does work is simply /pagename (or /foldername/pagename for that matter). Perhaps they have updated that since you produced the vid..? (wouldn't be surprised if they did that in response to developers having a hard time with that unintuitive "/appname;component/" way with no assistance from VS whatsoever)

  • Clint RutkasClint I'm a "developer"

    @Sven: You actually don't have to do it that way.  There is a much easier way. For this example if you just had your NavigateUri="/View/Page1.xaml" you'd be fine.  This also would work if you did NavigateService.

    NavigationService.Navigate(new Uri("/Views/Page1.xaml", UriKind.Relative));

  • it is COLON not SEMI colon in the path. The video was just clear enough to see that although bob says semi colon it might be a colon and after an hour of messaging about thinking I had the terms in the path wrong, I tried /appname:folder/filename.xaml and it worked.

     

  • Sevsend2sev The Beast

    Hi there

    I just wanted to ask if "AppPhoneService.State["value"]" is the way to keep values like Sessions in asp.net or no. Is there anything else like Sessions here?

  • BrendanBrendan

    Like Sven the "/NavigatingBetweenP..." does not work (using VS2010 VB .NET) but simply "/folder/file" does work.

  • I tried mine with colon : and it didnt work, then with semi colon ; and it didnt work. then all I did was changed the p in page1.xaml to a capital and it worked, then when I went back to the URI it was in lower case and it still worked. very strange. But cool video anyway

  • Jaguma GamesJaguma The only epicly awesome person to fail at succeeding to fail at succeeding.
    Brilliant. Thanks for this. I have been following your tutorials since the first one. They have been the BEST tutorials for any programming language I have found :)
  • I have a question related to the final part of this tutorial where Bob overrode the navigate to/from methods. He did this in order to ensure that previous input was stored and displayed correctly after navigating back through the hyperlink button. He stated that he needed to do this as the hyperlink button caused a new instance of the mainpage to be created.

    I am presuming that overriding the methods does not prevent the creation of a new main page instance but simply populates the new instance with the correct data.

    Does this mean that the application will now have 2 instances of main page loaded in memory? If yes, How do you ensure that your navigation from a hyperlink returns to the already instantiated page?

    You could possibly create an application with many means of navigating to a given page. Having multiple instance of the same page loaded into memory seems rather wasteful.

  • SewoldtSewoldt

    @made_rdj Those were so interesting questions. I tried to guess some answers. I think that when you navigate away from a page, that instance of the page is always destroyed. It seems logical because the page is no longer shown, and when you navigate again into the page, another instance of the page is created, so, there is always only one instance of that page. When you navigate back to the page by using the back button, a new instance of the page is created, but is populated with data that Silverlight stored somewhere. I guess you're always getting a fresh instance of the page (populated with data or no depending on whether you are using the back button or a hyperlink) and there are no unreachable multiple instances of the page wasting the memory.

  • YanivCYanivC

    Wondering why he went his route with vb.net when this works fine:
    Dim str as String = String.Empty
    NavigationContext.QueryString.TryGetValue("language", str)

  • Quick question if I may. When using the "NavigationService" class there is a method called... GoBack(). Is there a reason it was not covered in this video? Say... maybe can present some unwanted issues? Or is it just one of those "Well here is another way to achieve the same result"?

    private void button1_Click(object sender, RoutedEventArgs e)
            {
                NavigationService.GoBack();
            }

    Great videos guys!!!

  • JeniJeni

    I have a question related to this video.
    Should we use only hyperlink button to navigate between the pages?
    cant we use button control? suppose if i want to go to next page after i click on the button,how can i do that? can anyone plsss tell me...

  • @Jeni.
    u can use button in place of hyperlink.Code is like that:-

     NavigationService.Navigate(new Uri("/AppName;component/Page.xaml", UriKind.Relative));

  • NishantNishant

    If I may ask then have a look at this article which has defined all the techniques with samples to pass data among pages in WP7.

    http://nishantcop.blogspot.com/2011/08/passing-data-between-pages-in-windows.html

    Rgds
    Nishant

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.