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

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -