Data binding or foreach for displaying files from isolated storage
I'm trying to learn how to write apps for Windows Phone 7.
I would like to know which method for displ开发者_运维知识库aying the contents of an isolated storage file is best.
I am currently using the foreach method where foreach string in storage, it will create and add a listboxitem and its contents to a listbox.
I am wondering whether as I currently do not have a Windows Phone device to test, if data binding would be less CPU intensive and therefore faster.
Thanks!
Its far too early for you to already be worrying about performance. Data binding would be the correct approach regardless of whether it would be faster. You should wait until you have a device on which to test before attempting to determine whether anything needs adjusting.
Its easier to make a working program faster than it is to make a fast program work.
Databinding won't help you get the contents out of file(s) if you need to read them before adding to the listbox.
It may help in simplifying your code if you can bind the listbox source to the data read from the file, rather than explicitly creating listboxitems yourself.
If you can share some code we may be able to advise on alternative/better methods of performing the same actions.
精彩评论