i have observablecollection<myclass> instance 20 elements in , set itemssource control. when try call clear() collection, becomes clean, after 4-5 seconds of freezing app. if don`t use value dependency property clears fast. doesn't take time when simply run (ctrl+f5 in visual studio) application instead of debugging.
never faced such slowness while working observablecollection , don't understand how fix this(even while profiling delay not shown). develop control itemssource property, can't unassign property value - clear collection - set property value again. custom control's handlers work fast. , app freezes after clear() call , before custom inotifycollectionchanged.collectionchanged event handler called.
well, while making own data grid, advise every 1 inspect standard wpf controls , how manage enumarables. in project while creating cells custom grid did set collections element datacontext cell:
cellcontainer.setbinding(grid.datacontextproperty, new binding { path = new propertypath(string.format("itemssource[{0}]", rowindex)), elementname = "myusercontrol" }); it useless binding, makes wpf track changes of collection every cell , costs time. better assign item value datacontext of cell container like:
cellcontainer.datacontext = myusercontrolinstance.itemssource /*.oftype<object>.skip(rowindex).firstordefault() or ilists:*/[rowindex];
Comments
Post a Comment