wpf - Performance issue - DataTemplate and DataBinding - 1st load -


here drawing of ui: enter image description here

i have list of elements @ top (clickme1 , clickme2). each of element have several information contained inside mylist want display inside customelement of listbox.

clickme1 clicked default. when click on clickme2, listbox taking 2-3 seconds before updating customelements information of clickme2. when switch again, it's updating right away problem visible first click. customelement has lot of different bindings clickme element (images , texts).

here code:

public observablecollection<customclass> mylist { get; set; }   <listbox x:name="mylistbox"     scrollviewer.horizontalscrollbarvisibility="visible" scrollviewer.verticalscrollbarvisibility="visible"      itemssource="{binding mylist}">         <listbox.itemtemplate>                 <datatemplate>                         <local:customelement x:name="mycustomelement"/>                 </datatemplate>         </listbox.itemtemplate>         <listbox.itemspanel>                 <itemspaneltemplate>                         <wrappanel orientation="horizontal"/>                 </itemspaneltemplate>         </listbox.itemspanel>         <listbox.itemcontainerstyle>                 <style targettype="{x:type listboxitem}">                     <setter property="overridesdefaultstyle" value="true" />                     <setter property="template">                         <setter.value>                             <controltemplate targettype="listboxitem">                                 <border x:name="border" borderbrush="transparent" background="black">                                     <contentpresenter />                                 </border>                             </controltemplate>                         </setter.value>                     </setter>                 </style>             </listbox.itemcontainerstyle> </listbox> 

i tried use virtualizingstackpanel instead of wrappanel did not improve anything.

any ?

when repopulate collection, assigning new observablecollection? or working on existing one?

you should populate collection "off-line" , bind it. or google observablecollection derivative supports "bulk insert". standard observablecollection send ui update every insert.

wrong:

mylist.clear(); mylist.add(...); 

right:

observablecollection<customclass> coll = new ... coll.add(...); mylist = coll; 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -