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 4099100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:23:22+00:00 2026-05-20T20:23:22+00:00

I am looking for a WPF control which is a hybrid of TreeView and

  • 0

I am looking for a WPF control which is a hybrid of TreeView and DataGrid, something like the Visual Studio debugger or QuickBooks contacts list etc.

Any other solution on how to handle editable hierarchical data in WPF will be very welcommed as well.

enter image description here

  • 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-20T20:23:23+00:00Added an answer on May 20, 2026 at 8:23 pm

    This seems to me like a reasonably straightforward thing to implement if you design your view model properly.

    You basically design the items the same way you would if displaying them in a normal data grid, i.e. each item has a property for each column. In all likelihood, your underlying data model is hierarchical, but the collection that the grid is bound to is going to be flattened, i.e. will contain an item for each node in the hierarchy irrespective of parent/child relationships.

    The item view model has some additional properties: Level, Children, IsExpanded, and IsVisible. Level is a count of the node’s ancestors, Children contains the child view model nodes, IsExpanded is used in the UI, and IsVisible is true if the node is visible. It also implements a property called VisibleDescendants:

    public IEnumerable<NodeViewModel> VisibleDescendants
    {
       get
       {
          return Children
                 .Where(x => x.IsVisible)
                 .SelectMany(x => (new[] {x}).Concat(x.VisibleDescendants)));
       }
    }
    

    You use Level, HasChildren, and IsExpanded in the style for the item in the control’s first column: they control the left margin and what kind of icon (if any) is displayed.

    You also need to implement ExpandCommand and CollapseCommand properties. The ExpandCommand is enabled if Children.Any() is true and IsExpanded is false, and the CollapseCommand is enabled if Children.Any() is true and IsExpanded is true. These commands, when executed, change the value of IsExpanded.

    And here’s where it gets interesting. The simple way to implement this may work for you: the items are exposed by a parent view model whose Items property is not a collection. Instead, it’s an enumerator that travels down the chain of child view models and yields only the visible nodes:

    public IEnumerable<NodeViewModel> Items
    {
       get
       {
          return _Items
                 .Where(x => x.IsVisible)
                 .SelectMany(x => (new[] {x}).Concat(x.VisibleDescendants));
       }
    }
    

    Whenever any descendant’s IsVisible property changes, the parent view model raises PropertyChanged for the Items property, which forces the data grid to repopulate.

    There’s a less simple implementation too, where you make the Items property a class that implements INotifyCollectionChanged, and that raises the proper CollectionChanged events when descendant nodes become visible/invisible, but you only want to go there if performance is an issue.

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

Sidebar

Related Questions

Im looking to create a control that would look like comic baloon. In WPF
I'm looking for an Image control for WPF which can rapidly change images. The
I'm looking for a WPF control that looks like an iPhone battery level. I
I am working on a Visual studio like application i.e. have a toolbox, an
I have a WPF control, that has a list of Investors, and in the
We are currently looking to create a text-editor in WPF (.NET 4.0) which will
Which WPF control allows listing of items and context menus on each of the
I am looking for an Accordion control for WPF .NET 4. I am aware
I am trying to bind a collection to wpf TreeView control using data templates.
I've been looking on the site http://wpf.codeplex.com/ and found the Ribbon control finding my

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.