Navigate to new Page in Codebehind using NavigationService

1k views Asked by At

I want to access my page to setup the XAML Page:

Dim Pg As New PageListPickerSelection
Pg.StartCalculating(199,"Z-UU", MyCalculationDataIEnumList, myImageSource)
App.NavigationService.Navigate(New Uri("/uc/ListPicker/PageListPickerSelection.xaml", UriKind.Relative))

But NavigationService.Navigate does not support Objects or referenced pages.

How is the correct procedure to show the own page?

Or asked in another way: How does the "ListPicker in the WP7" solve this when showing his separated page?

Regards

2

There are 2 answers

0
Marius Bughiu On

You could use a static class in which you have a couple of static values which you write when leaving the first page and read when opening the second page.

If you don't like static classes / variables you could use a singleton.

2
Unknown1987 On

If I understand your question, you are asking how to configure a page before navigating to it, correct? The navigation service will create your pages as you navigate to them on the fly. It is not possible to give the navigation service the page as an object If you need to pass data into a page you can use the normal method of appending params to a URI as such (using c# as I am not familiar with VB):

NavigationService.Navigate(new Uri("/uc/ListPicker/PageListPickerSelection.xaml?Param1=" + (199).ToString() + "&Parm2=" + "Z-UU", UriKind.Relative));

Later in the PageListPickerSelection's OnNavigatedTo() method you can parse the parameters again as such:

string p1 = this.NavigationContext.QueryString["Param1"];
string p2 = this.NavigationContext.QueryString["Param2"];