2011-10-07 28 views
0

將圖片添加到列表框的最佳方式是什麼?Windows Phone 7將圖片添加到列表框的最佳方式?

我有大約10 RSS項目,什麼是包含圖像的URL(所有圖片爲300 * 300像素) 約300圖片

我的壞算法是下一個:

1, download all xml file, and parse all with XDocument (i have then title and the image url) 
2, using a datatemplate with an image and a textblock with Binding 
3, lb.ItemsSource=alldatas; 

這是很慢和laggy算法,在WPF7中做這件事的正確方法是什麼?

回答

1

這聽起來並不像你在做任何特別錯誤的事情。我猜這個問題是,300圖像正在加載,這是導致UI線程被阻止。我會建議閱讀關於David Anson's LowProfileImageLoader,這減少了在UI線程上完成的工作量。

另外,你是否將這些元素加載到列表框?如果是這樣,我寫了更多lightweight approach here

+0

我喜歡使用virtualizingstackpanel,但我不知道如何從代碼中使用virtualizingstackpanel。你能幫我嗎? – lacas