【发布时间】:2014-03-05 17:21:43
【问题描述】:
我正在创建一个应用程序,我通过 Web 服务从 DB 获取数据并将其显示在我的 mainpage.xaml 的列表框中(有关不同事件的数据,例如 EventTitle、Date 等)目前我已经设置因此,选择列表框中的项目时,应用程序导航到“EventDetail”页面,该页面仅从列表中描绘出所选数据。
我需要帮助的是获取此用户选择的数据并将其带到要使用的导航页面。我正在努力以最简单的方式弄清楚;如何将用户选择的列表框项目转移到定义的页面以更清晰的方式显示它并使用此数据。
最好我想在导航页面内的单独文本块中显示每个文本块/单元格(事件标题、日期等),以便它们可以适当地布置,但只有选定字段数据的列表框可以完成这项工作。
这里是相关的 Xaml 代码:
<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>
这里是相关的C#编码:
private void FirstListBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
EventServiceReference1.Event myEvent = (EventServiceReference1.Event)FirstListBox2.SelectedItem;
NavigationService.Navigate(new Uri("/EventPageTemp.xaml", UriKind.Relative));
}
如果您能帮我解决这个问题,我将不胜感激。
【问题讨论】:
标签: c# xaml windows-phone-7 listbox