2013-01-09 64 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); 
    } 
相關問題