2013-01-09 63 views
0

是否可以将LINQ查询的结果作为参数发送到WP7中的另一个.xaml文件。 如果是,那么你能否通过示例来解释一下。 在此先感谢将LINQ元素作为参数传递给另一个.xaml wp7

这里是我的代码

XDocument xml = XDocument.Load("VideoContent.xml"); 
var content = from query in xml.Descendants("Video") where (string)query.Element("Clip") == parameter 
       select new Video() { File = (string)query.Element("File") } 

现在我需要在文件传递字符串使用的NavigationService其他的.xaml。

P.S我很新的WP7和LINQ

+0

LINQ查询或结果的“文件”的字符串值? LINQ的格式是什么?] – nkchandra

+0

是LINQ的结果。 XDocument xml = XDocument.Load(“VideoContent.xml”); (字符串)query.Element(“Clip”)==参数 select new Video() { File =(string)query.Element(“文件“) }; 现在我需要使用NAvigationService将File中的字符串传递给另一个.xaml。 P.S我对WP7和LINQ很新颖 – Tulika

回答

0

如果你想传递的字符串值,你可以把它作为导航参数。

NavigationService.Navigate(new Uri("/NewPageName.xaml?file="+content.First().File, UriKind.Relative)); 

,然后在新页面的处理的OnNavigatedTo,得到这样的LINQ查询这

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
    { 
     string file; //declare this before the page constructor 

     NavigationContext.QueryString.TryGetValue("file", out file); 
    } 
相关问题