WPF Datagrids slow when using Auto column sizes -
when expand expander in code below, application becomes sluggish , takes 2-3 seconds respond resize/move events triggered user. if set second column <columndefinition width="250"/>
response time remains optimal. missing here? (i'm need ui per below without sluggishness)
<usercontrol> <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition /> <columndefinition width="auto" /> </grid.columndefinitions> <toolbar .. /> <datagrid grid.row="1" itemssource="{binding collection1}" .. /> <expander grid.column="1" grid.rowspan="2"> <datagrid itemssource="{binding collection2}" .. /> </expander> </grid> </usercontrol>
fyi: suspect row virtualization not being used when width=auto set , datagridrow objects being created entire bound data source...
update following not remove sluggishness;
<grid.columndefinitions> <columndefinition /> <columndefinition width={binding elementname=expander, path=width} /> </grid.columndefinitions> .. <expander name="expander" grid.column="1" grid.rowspan="2"> <datagrid itemssource="{binding collection2}" width="300" .. /> </expander>
the problem if set columnwidth
auto
, column width calculated depending on content, here, datagrid. have second column large (even though might not see depending on layout) , datagrid's columns drawn every time.
so basically, loose benefits of columnvirtualization
(not rowvirtualization
).
this same reason why should never put datagrid
scrollviewer
.
solution
set virtualizingstackpanel.isvirtualizing="true"
on grid
if not work, might have take care of resizing yourself, no real option there.
Comments
Post a Comment