views:

502

answers:

1

Main page consists of a listbox, frame and few hyperlinks. On clicking hyperlink, appropriate page is loaded in the frame.

How can I pass the selected item value of the listbox on Main page to page being loaded(ex: About page) through query string in silverlight 3?

Any pointers will be highly appreciated.

+1  A: 

As per the MSDN page, you can specify a query string in the format

<uriMapper:UriMapping Uri="/Products/{type}" 
  MappedUri="/Views/ProductDetail.xaml?producttype={type}">
</uriMapper:UriMapping>

I do not know how to link the type to a value through XAML but on navigation to that page, you can add an OnClick event instead of a navigateuri. In the OnClick event you will specify something like the following:

private void Link2_Click(object sender, RoutedEventArgs e)
{
    Uri x = new Uri(String.Format(/Products/{0},yourcombo.SelectedItem), UriKind.Relative);

    //ContentFrame is the Navigation Frame
    ContentFrame.Navigate(x);
}

This will navigate to the ProductDetail.xaml page. From here you can get the producttype value by using string type = this.NavigationContext.QueryString["producttype"];

Tim Heuer also has an excellent web cast on the navigation solutions.

Johannes
Thank you Johannes
funwithcoding