Node.Visibility = visible ? Visibility.Visible : Visibility.Collapsed / private void ApplyFilter(TreeViewItem node, ShopCategory item)īool visible = filter = null || filter(item) / /// Filters categories if the property /// is set by simply setting the /// property to if the item does /// not match the filter. TreeViewItem node = base.CreateTreeViewItem(item) / /// /// protected override TreeViewItem CreateTreeViewItem(ShopCategory item) This /// is somewhat redundant (as we're also handling ), /// but ensures we also consider root nodes. / /// Immediately applies the filter on newly created items. apply filter foreach (TreeViewItem childNode in treeNode.Items)ĪpplyFilter(childNode, (ShopCategory)childNode.Header) make sure child nodes are being created base.OnNodeExpanded(treeNode) / /// protected override void OnNodeExpanded(TreeViewItem treeNode) / /// Applies the filter on all child nodes. recreate the tree in order to apply the filter on //all currently visible nodes //-> of course, this could be optimized, but it does the job Set to /// null in order to disable filtering. / /// Defines a filter for items that are bound to the tree. I must say I’m quite satisfied – as the control provides me with virtual methods to intercept everything, the whole thing took about 2 minutes to set up □
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |