c# - Is Clearing ObservableCollection Recommended before Adding Items to it? -
i need filter observablecollection have items in it. approach better?
// assigning filtered result directly filteredobservablecol = filteredcollectioncopy.where(i=> i.age > 25).toobservablecollection();
or
// clearing collection first filteredobservablecol.clear(); filteredobservablecol = filteredcollectioncopy.where(i=> i.age > 25).toobservablecollection();
you use collectionviewsources
instead of observablecollection bind to. there can apply filtering.
icollectionview mycollection { get; private set; } public void loaddata() { var myobservable = //... load/create list mycollection = collectionviewsource.getdefaultview(myobservable); mycollection.filter = item => ((typeofitem)item).name = "bob"; }
Comments
Post a Comment