Windows Phone 7 ListBox has bad performance with just a few items? -


i'm writing simple dictionary app gives suggestions words type. suggestions displayed in listbox , each time query changes, 10 suggestions should appear.

unfortunately, performance low @ moment. takes second results appear , don't understand why. eqatec profiler shows methods running smoothly. i've confirmed putting stopwatch around code. i've experimented number of suggestions, , performance increase fewer items.

this leads me conclude rendering listbox (which presume happens outside of methods) blame lack of performance.

  • does rendering 10 items in listbox take more 250ms?
  • how can put small number of words on screen?

edit: way fill listbox straightforward. right way?

resultslistbox.items.clear(); foreach (string s in suggestions.words) {   resultslistbox.items.add(s); } resultslistbox.selectedindex = suggestions.matchindex; 

what see here it: default listbox, string items, no templates. violate 1 of these principals?

  • ensure have item data template in fixed sized container (grid).
  • avoid/remove using complex converters, when same information can provided data object.
  • avoid/remove nested structures, example listbox in listbox item.
  • strongly recommended not use user control inside data template.
  • avoid/remove custom controls data template

the link below contains demonstration of listbox performance in simple project.

the project shows alternative (faster) way display list, using grid buttons. list not scrollable , therefore not real solution.

http://www.mediafire.com/?jypcfm4cs3nvo5c

remember run project on device, because emulator has different performance. i've tested on samsung omnia 7.

it sounds you're creating own autocompletebox. there specific reason not using 1 in toolkit?

i expect time taken update listbox dependent upon: how you're updating it; complexity of listbox; , whatever-else on page.
in haven't provided details of these possible take long.


edit
alternative autocompletebox (in theory shouldn't need scroll results of this--just enter more characters filter further.) i've done experimentation , following seems work best. uses stackpanel inside scrollviewer , reuses existing items, rather creating new ones.

<scrollviewer height="629" margin="0,139,0,0" width="480">     <stackpanel name="listbox1" /> </scrollviewer> 

cs:

    private void initializeresultsgrid()     {         ...          (int = 0; < 26; i++)         {             ...              listbox1.children.add(new textblock()); 

and

private void slowfill(string basestr) {     (int = 0; < buttons.count; i++)     {         (listbox1.children[i] textblock).text = basestr + (char)(i + 'a');     } 

when timed it, slower using grid performace seemed fine me on lg-e900


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -