This is partly due to this topic: Reading Async XML in Windows Phone 7
I am developing a Windows Phone application and I have a search function in the Search.xaml.cs file. It is called by pressing a button, it creates a search query and calls DownloadStringInBackground with it
private void SearchQuery(object sender, EventArgs e) { string temp = "http://api.search.live.net/xml.aspx?Appid=myappid&query=randomqueryhere&sources=web"; DownloadStringInBackground(temp); } public static void DownloadStringInBackground(string address) { WebClient client = new WebClient(); Uri uri = new Uri(address); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadStringCallback); client.DownloadStringAsync(uri); } private static void DownloadStringCallback(Object sender, DownloadStringCompletedEventArgs e) {
finalResult is stored as
public static string[] finalResult;
in the search class. My question is: where can I put the Navigate command (NavigationService.Navigate (new Uri ("/Result.xaml", UriKind.Relative));)? I tried to do this in a callback, but I got a nullobject exception due to a static keyword. How can I guarantee that finalResult has been populated and that I can go to Result.xaml and reference the data in finalResult on this page. Alternatively, how can I pass words or finalResult to Result.xaml?
Thanks for watching :)
search windows-phone windows-phone-7 navigation
Freakishly Dec 14 '10 at 10:18 2010-12-14 10:18
source share