wpf - Checkbox column flickering when scrolling -
i want make simple table, whit checkbox column. created table datagrid , bound list of custom objects.
everything works fine, except notice strange flickering effect, when scroll table.
it looks this: https://imgrush.com/-ji2fpnf385o
what's problem? how can rid of this?
my xaml code:
<window x:class="mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="723.251"> <grid> <datagrid x:name="maindatagrid" margin="22,21,133,58" autogeneratecolumns="false" selectionmode="single" selectionunit="cell" canusersortcolumns="false" isreadonly="true" > </datagrid> <button content="populate" horizontalalignment="left" margin="592,21,0,0" verticalalignment="top" width="75" click="button_click" isdefault="true"/> <label x:name="lbl1" content="label" horizontalalignment="left" margin="592,48,0,0" verticalalignment="top"/> </grid> </window> and vb code:
imports cadnet_filereader.cadnet_filereader class mainwindow dim outlist new list(of tags) dim selectionlock new boolean private sub button_click(sender object, e routedeventargs) dim tablecolumn_01 new datagridtextcolumn tablecolumn_01.binding = new binding("tagitem") tablecolumn_01.header = "tag name" tablecolumn_01.width = 200 me.maindatagrid.columns.add(tablecolumn_01) dim tablecolumn_02 new datagridcheckboxcolumn tablecolumn_02.binding = new binding("tagcheck") tablecolumn_02.header = "toogle" tablecolumn_02.width = 30 me.maindatagrid.columns.add(tablecolumn_02) dim templist new list(of string) dim path string = "c:\epic\apps\elementcounter\epic_template.txt" templist = readtemplatefile(path) dim thisitem new tags = 0 templist.count - 1 thisitem = new tags thisitem.tagitem = templist.item(i) thisitem.tagcheck = false outlist.add(thisitem) next maindatagrid.itemssource = outlist end sub private sub maindatagrid_selectionchanged(sender object, e selectionchangedeventargs) handles maindatagrid.selectionchanged end sub private sub maindatagrid_selectedcellschanged(sender object, e selectedcellschangedeventargs) handles maindatagrid.selectedcellschanged dim selectedrow integer dim selectedcolumn integer selectedrow = maindatagrid.items.indexof(maindatagrid.currentitem) selectedcolumn = maindatagrid.selectedcells.item(0).column.displayindex lbl1.content = "selected row = " & selectedrow & "; " & selectedcolumn if selectedcolumn = 1 if outlist.item(selectedrow).tagcheck = false outlist.item(selectedrow).tagcheck = true else outlist.item(selectedrow).tagcheck = false end if end if end sub end class list item used:
<system.serializable()> public class tags implements inotifypropertychanged public property tagitem string ' new property private _newdataproperty string public property tagcheck set(value) _newdataproperty = value _propertychanged("tagcheck") end set return _newdataproperty end end property ' change events private sub _propertychanged(optional byval propertyname string = nothing) raiseevent propertychanged(me, new propertychangedeventargs(propertyname)) end sub private event propertychanged(sender object, e propertychangedeventargs) implements inotifypropertychanged.propertychanged public sub serializeme() end sub end class
well, problem is, cells rendered @ moment scroll them. first checkbox appears, selection value. described in smooth scrolling, try set
scrollviewer.cancontentscroll=false which draw whole list @ once (and deactivates virtualization of contents) might become real problem performance if list contains lot of entries.
Comments
Post a Comment