c# - Sorting ListBox items clears selection -
i have listbox
issynchronizedwithcurrentitem="true"
problem if select more 1 item , alter sorting order end 1 item selected.
private icollectionview filecollectionview; filecollectionview = collectionviewsource.getdefaultview(filecollection); this.fileslb.itemssource = collectionviewsource.getdefaultview(filecollectionview); observablecollection<filedata> _filecollection = new observablecollection<filedata>(); public observablecollection<filedata> filecollection { { homecoming _filecollection; } } private void sortfiles() { using (filecollectionview.deferrefresh()) { filecollectionview.sortdescriptions.clear(); filecollectionview.sortdescriptions.add(new sortdescription(t.sortfiles.sortby, t.sortfiles.sortdirection)); }
why happening , how can prepare it?
because clearing list. prepare storing selection , reselecting after refilled list.
c# wpf
No comments:
Post a Comment