Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 746787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:07:51+00:00 2026-05-14T14:07:51+00:00

This one is a follow-up question. I filter the top level nodes of a

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:07:52+00:00Added an answer on May 14, 2026 at 2:07 pm

    In cases such as this Reflector is always your friend. I presume that ICollectionView.Refresh() is called internally to reflect the changes caused by adding/removing a filter. This effectively re-enumerates the nodes in the TreeView.

    To compensate for this you can always grab the state of all tree items and re-apply them after a refresh. This may not be the easy solution you were looking for.

    You may also want to try to set MyFilter once and call ICollectionView.Refresh() programmatically. Your MyFilter should then filter according to _filterCheckBox.IsChecked value. This could make a difference but these are all merely ideas. You must try them yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is like a follow-up question to this one . Basically what I'm doing
This is more like a follow up question to this one: .htaccess - how
This a follow-up question to this one . Now I would like to convert
This is a follow-up question to this one . Consider this example: #include <iostream>
Just a follow up question to this one here => link Is it possible
I have a follow-up question to this one . I created a new form,
I have a follow up question to this one . Now that I have
This question is a follow on from this one ... I am binding to
This is a follow-on question from the one I asked here . Can constraints
This is really a follow on question to a previous one , where I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.