c# - CollectionViewSource.SortDescriptions not work when binding items are created using Parallel -
i'm using vs2013, .net4.5, wpf desktop application.
xaml:
<collectionviewsource x:key="cvs" source="{binding obspasses, mode=oneway}"> <collectionviewsource.sortdescriptions> <scm:sortdescription propertyname="startdate"/> </collectionviewsource.sortdescriptions> </collectionviewsource>
cs:
this.obspasses = new observablecollection<passviewmodel>( passes.asparallel().select(x => new passviewmodel(x)));
if remove .asparallel()
, items sorted, if added, items in disorder. feel little strange. doesn't sortdescription guarantee ui items sorted no matter in order items added in background?
in code demo didn't bind collectionviewsource, collection itself. try replacing
<itemscontrol itemssource="{binding obsfoos, mode=oneway}" >
with
<itemscontrol itemssource="{binding source={staticresource cvs}}" >
Comments
Post a Comment