private void TxtKeyword_Completed(object sender, EventArgs e) { var curKeyword = txtKeyword.Text.Trim(); if (curKeyword.Equals(oldKeyword, StringComparison.OrdinalIgnoreCase)) { return; } else { TheTreeView.Clear(); if (curKeyword.Equals("")) { TheTreeView.RootModels = rootModelItems; TheTreeView.FirstCreateUIElement(); oldKeyword = ""; return; } var search_result = new ObservableCollection <TreeNodeModel>(); var found = TreeViewEx.SearchModels(rootModelItems, curKeyword.ToUpper(), ref search_result); TheTreeView.RootModels = search_result; TheTreeView.FirstCreateUIElement(); oldKeyword = curKeyword; } }