Reputation: 2513
I currently have a listbox which is fed by a XML file. I'm using a webclient to grab the XML and then using the following code to parse it into the listbox;
XElement xmlSearch = XElement.Parse(e.Result);
lstbSearch.ItemsSource = from Search in xmlSearch.Descendants("e2event")
select new GetSearch
{
e2eventtitle = Search.Element("e2eventtitle").Value,
e2eventid = Search.Element("e2eventid").Value
};
Now the file can be as big as 150kb, Which can take some time on a phone. So i was wondering if i could make it display in the listbox as the data is received. What's the best method to use whilst keeping good performance?
Many thanks, Nathan
Upvotes: 3
Views: 336
Reputation: 3138
The web client will not fire the completed event until all the data has been recieved so I will not be possible to view the data as it arrives.
Upvotes: 3
Reputation: 66882
In addition to @harryover's answer, using WebClient or HTTPWebRequest won't really allow you to do gradual rendering:
The best way to do what you want to do is probably to split your data up into separate HTTP requests - make lots of smaller requests instead of one big one.
Upvotes: 2