c# - WPF DataGrid: IsVirtualizingWhenGrouping="True" not working -


i have datagrid has collectionviewsource bound it's itemsource property:

<datagrid grid.row="0" rowbackground="#10808080" alternatingrowbackground="transparent"           horizontalalignment="stretch" verticalalignment="stretch"           itemssource="{binding source={staticresource bookingsviewsource}}"           rowheight="27"           virtualizingpanel.isvirtualizingwhengrouping="true"           virtualizingpanel.iscontainervirtualizable="true"           virtualizingpanel.scrollunit="item"           autogeneratecolumns="false">      <datagrid.columns>         <datagridtextcolumn binding="{binding date, stringformat=dd.mm.yyyy}" header="date"/>         <datagridtextcolumn binding="{binding path=customers.name}" header="customer"/>         <datagridtextcolumn binding="{binding path=customers.street}" header="adress"/>     </datagrid.columns>      <datagrid.groupstyle>         <groupstyle>             <groupstyle.containerstyle>                 <style targettype="{x:type groupitem}">                     <setter property="template">                         <setter.value>                             <controltemplate>                                 <expander header="{binding path=name}" isexpanded="true">                                     <itemspresenter />                                 </expander>                             </controltemplate>                         </setter.value>                     </setter>                 </style>             </groupstyle.containerstyle>         </groupstyle>     </datagrid.groupstyle> </datagrid> 

bookingsviewsource defined as

<collectionviewsource x:key="bookingsviewsource"                       d:designsource="{d:designinstance {x:type database:bookings}}">     <collectionviewsource.groupdescriptions>         <propertygroupdescription propertyname="providerid"/>     </collectionviewsource.groupdescriptions> </collectionviewsource> 

and get's filled in code behind section. doing fine fast , smooth without grouping. when added grouping <propertygroupdescription propertyname="providerid"/> datagrid needs around 1 minute load.

in .net 4.5 there new property called virtualizingpanel.isvirtualizingwhengrouping , set true loading time not decreasing.

i can not figure out why. ideas?

from book: macdonald m. - pro wpf 4.5 in c#

a number of factors can break ui virtualization, when don’t expect it:

  • putting list control in scrollviewer: scrollviewer provides window onto child content. problem child content given unlimited “virtual” space. in virtual space, listbox renders @ full size, of child items on display. side effect, each item gets own memory-hogging listboxitem object. problem occurs time place listbox in container doesn’t attempt constrain size; example, same problem crops if pop stackpanel instead of grid.
  • changing list’s control template , failing use itemspresenter: itemspresenter uses itemspaneltemplate, specifies virtualizingstackpanel. if break relationship or if change itemspaneltemplate doesn’t use virtualizingstackpanel, you’ll lose virtualization feature.
  • not using data binding: should obvious, if fill list programmatically— example, dynamically creating listboxitem objects need—no virtualization occur. of course, can consider using own optimization strategy, such creating objects need , creating them @ time they’re needed. you’ll see technique in action treeview uses just-in-time node creation fill directory tree in chapter 22. if have large list, need avoid these practices ensure performance.

also, in case issue caused mahapps.metro styles.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -