xaml - UI-efficient filtering of WPF TreeView -


i need make searchable treeview. if item matches search text, of parents automatically match , expanded. doesn't match loses visibility.

here (sample) interface , filtering code:

interface itreeitem : inotifypropertychanged {     ilist<itreeitem> children { get; }     string header { get; }     bool isexpanded { get; set; }     bool isvisible { get; set; } }  void filter(itreeitem item, string text) {     foreach (var subitem in item.children) {         filter(subitem, text);     }     if (item.header.indexof(text, stringcomparison.currentcultureignorecase) >= 0)         item.isvisible = true;     else {         foreach (var subitem in item.children) {             if (subitem.ismatch) {                 item.isvisible = true;                 item.isexpanded = true;                 return;             }         }         item.isvisible = false;         item.isexpanded = false;     } } 

this question isn't algorithm; works fine , isn't bottlenecking far can tell. problem notifypropertychanged isexpanded on of nodes. when tree has non-trivial number of items (i can significant delay 100 items 100 subitems each) there's huge halt ui bombarded these property changes.

i've considered rebuilding list , assigning treeview's itemssource manually whenever search text changes, unrelated feature (adding/renaming items) means solution require lot of bookkeeping.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -