I have enabled search in my MonoTouch.Dialog. After each keystroke I call the database, get the updated list and then re-create the Root. The tableview is always empty though after I regenerate the Root, even though I can confirm that I am adding elements each time.
In a situation where the entire list needs to be recreated each time the user types in the search bar, do I need to recreate the Root each time, or clear it and re-populate it?
I have tried both ways but the tableview never renders anything after I try to regenerate it.
this.SearchTextChanged += (sender, args) => {
query = args.Text;
CreateRoot();
};
void CreateRoot()
{
if(this.Root!=null)
this.Root.Clear();
Section section = new Section();
List<TermItem> terms = LegalDatabase.GetTerms(query, SearchScope);
foreach (TermItem term in terms)
{
var eTerm = new TermElement(term.ID);
section.Add(eTerm);
}
terms = null;
this.Root.Add(section);
}