Silverlight Navigation LINQ问题 [英] Silverlight Navigation linq problem
本文介绍了Silverlight Navigation LINQ问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,我有一个LINQ查询(如下),该查询下载一些XML数据,然后在列表框中显示该数据. (listBox1)
Hi,
Basically I have a LINQ query (below) that downloads some XML data and then displays that data in a listbox. (listBox1)
XElement xmlScan = XElement.Parse(e.Result);
listBox1.ItemsSource = from channel in xmlScan.Descendants("item")
select new ScanItem
{
title = channel.Element("title").Value,
description = strip2(strip(channel.Element("description").Value)),
};
在选择项目时,然后我想借此从所选项目的标题字段的文本和附文用此导航到一个页面.我已经试过了:
Then when an item is selected I want to take the title field text from the selected item and use this to navigate to a page with the text attached. I have tried this:
private void ListBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + MainListBox.SelectedIndex, UriKind.Relative));
}
但是,它所做的只是导航到DetailsPage,然后选择没有标题字段的所选项目号.
However all it does is navigate to DetailsPage and then the item number that was selected no the title field.
Any help is much appreaciated.
推荐答案
您尚未完全指定ScanItem的外观,但我认为您想执行以下操作:
You haven''t exactly specified how ScanItem looks but I think you want to do something like this:
NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" +
((ScanItem)MainListBox.SelectedItem).title, UriKind.Relative));
这篇关于Silverlight Navigation LINQ问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文