windows phone 7 - Listbox-selecting items that are read from isolatedstorage -
ok, here simple code, explain need do:
isolatedstoragefile store = isolatedstoragefile.getuserstoreforapplication(); streamwriter writefile; if (!store.directoryexists("savefolder")) { store.createdirectory("savefolder"); writefile = new streamwriter(new isolatedstoragefilestream("savefolder\\savedfile.txt", filemode.createnew, store)); } else { writefile = new streamwriter(new isolatedstoragefilestream("savefolder\\savedfile.txt", filemode.append, store)); } stringwriter str = new stringwriter(); str.write(urlholder.text); writefile.writeline(str.tostring()); writefile.close();
so, have isolatedstorage keep links, read textbox(urlholder), on other side, read links , put them in listbox:
isolatedstoragefile store = isolatedstoragefile.getuserstoreforapplication(); streamreader readfile = null; try { readfile = new streamreader(new isolatedstoragefilestream("savefolder\\savedfile.txt", filemode.open, store)); string filetext = readfile.readtoend(); bookmarklistbox.items.add(filetext); readfile.close(); } catch { messagebox.show("need create directory , file first."); }
the thing writing , reading ok, problem when links in listbox, when want select 1 of them selects of them...i tried everything, no result, so, if knows solution, please write...thanks!
you're reading whole file single string , adding single item in listbox.
you need add lines/links separate items. try like:
while (var item = readfile.readline()) { bookmarklistbox.items.add(item); }
Comments
Post a Comment