WPF: Filter TreeView without collapsing it's nodes
Posted
by Julian Lettner
on Stack Overflow
See other posts from Stack Overflow
or by Julian Lettner
Published on 2010-04-23T16:41:32Z
Indexed on
2010/04/23
16:43 UTC
Read the original article
Hit count: 1351
This one is a follow-up question.
I filter the top level nodes of a TreeView
control like shown below.
private void ApplyFilterHandler(object sender, RoutedEventArgs e)
{
if (_filterCheckBox.IsChecked.Value)
CollectionViewSource.GetDefaultView(TopLevelNodes).Filter += MyFilter;
else
CollectionViewSource.GetDefaultView(TopLevelNodes).Filter -= MyFilter;
}
.
<TreeView ItemsSource="{Binding TopLevelNodes}">
...
</TreeView>
When the user applies the filter all nodes get collapsed.
Question
How can I hide certain nodes in a tree while retaining the expand state of the other nodes?
Can someone explain, what happens internally on ICollectionView.Filter += MyFilter
.
Thanks for your time.
© Stack Overflow or respective owner