I am creating an app where I have obtained data from a DB Via Web service and displaying it within a listbox within my mainpage.xaml (data about different events being held e.g. EventTitle, Date etc.) At the moment I have set it up so that when an item within the list box is selected the application navigates to an "EventDetail" page which portrays only the selected data from the list.
What I need help with is taking this user selected data and taking it to the navigated page to be used. I am struggling to figure out in the simplest way; how to transfer a listbox item which has been selected by the user to the defined page to display it in a more clear way and to use this data.
Preferably I would like to display each textblock/cell (EventTitle, Date etc) in separate text blocks within the navigated page so that they can be laid out appropriately but a list box with only the selected fields data would do the job.
Here is the relevant Xaml code:
<ListBox Height="496" HorizontalAlignment="Left" Margin="-4,155,0,0" Name="FirstListBox2" VerticalAlignment="Top" Width="460" SelectionChanged="FirstListBox2_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="132">
<StackPanel Width="370">
<TextBlock Text="{Binding EventID}" Foreground="#FFC8AB14" FontSize="24" />
<TextBlock Text="{Binding EventList}" TextWrapping="Wrap" FontSize="36" />
<TextBlock Text="{Binding Date}" TextWrapping="Wrap" FontSize="24" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Here is the relevant C# coding:
private void FirstListBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
EventServiceReference1.Event myEvent = (EventServiceReference1.Event)FirstListBox2.SelectedItem;
NavigationService.Navigate(new Uri("/EventPageTemp.xaml", UriKind.Relative));
}
Please if you could help me with this problem I would very much appreciate.