0

I have a listbox that is filled up with JSON data. Now when I press on a item inside that listbox, I should go to detail page about that item. I have this code for my listbox.

<ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0,5,0,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="350"/>
                                    </Grid.ColumnDefinitions>
                                    <Image Source="{Binding imgurl}" MaxHeight="110" MaxWidth="110" />
                                    <TextBlock Grid.Column="1" Text="{Binding title}" TextWrapping="Wrap" Margin="10,0,2,0" FontSize="20" />
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>

Now for navigating I do this in the PhoneList_SelectionChanged.

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

I know that I can pass values to this URI using ?value1=testtest But my question is now I can I pass those values to the URI?

any help?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Steaphann
  • 2,797
  • 6
  • 50
  • 109
  • Here's how Caliburn micro Builds a URI appending data if needed. http://caliburnmicro.codeplex.com/SourceControl/changeset/view/9d5d0047e30e#src/Caliburn.Micro.WP71.Extensions/UriBuilder.cs – Derek Beattie Jan 16 '13 at 00:52

1 Answers1

0

In selection changed event you have to know the object which you have selected. The code structure is as follows:

PhoneModel model = PhoneList.SelectedItem as PhoneModel;
NavigationService.Navigate(new Uri("/Views/NewsDetail.xaml?value1="+model.title, UriKind.Relative));

PhoneModel is the model of items list which you are binding to the listBox. The above code snippet sends title in the navigation. You have to replace it with your requirement.

For sending more than one parameters in navigation you have to follow this pattern:

PhoneModel model = PhoneList.SelectedItem as PhoneModel;
NavigationService.Navigate(new Uri("/Views/NewsDetail.xaml?value1="+model.title+"&value2="+model.imgurl, UriKind.Relative));
Swapnika
  • 480
  • 4
  • 14