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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:39:52+00:00 2026-05-27T21:39:52+00:00

I have an architect question: I want to use Tree View to display some

  • 0

I have an architect question:

I want to use Tree View to display some categories and on each categories if user clicks, need to show total product for that category.

What approach do I need to take?

Currently, I am trying to do:
1) Get Data from Database and load it to DataTable and DataTable is accessable from xaml.
2) Calling DataTable from xaml and binding TreeViewItem from dataTable Column…i.e.,

<TreeView ItemsSource="{Binding ElementName=_this, Path=SubCategoriesTable}" Name="trSubCategories">
<TreeView.ItemTemplate>
    <DataTemplate>
        <TreeViewItem Header="Home">
            <TreeViewItem Header="{Binding Path=sub_category_name}"></TreeViewItem>
        </TreeViewItem>
    </DataTemplate>
</TreeView.ItemTemplate>

I don’t know is it a right approach to go? Or Should I add TreeViewItem in my code behind by looping though each datatable row and column?

Please help!

  • 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-27T21:39:53+00:00Added an answer on May 27, 2026 at 9:39 pm

    Use a HierarchicalDataTemplate and bind your TreeView accordingly. You can use any object type as the backing for the binding; it doesn’t need to be a DataTable.

    You should avoid building out TreeViewItem‘s in your code behind. It is simply not needed and makes down stream management more cumbersome then it needs to be.

    As noted by ChristopherS; Josh Smith has an excellent article on a TreeView with MVVM. Bea Stoliz also has a nice post on displaying grouped data in a TreeView.

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

Sidebar

Related Questions

I have some type an architect(?) question I develop an application, based on Spring
i have some questions of how to use the Entity Framework in an enterprise
I have to architect a commercial vehicle fleet tracking system. Each vehicle (a few
I have a question regarding the C# code generation capabilities of Enterprise Architect. How
I have a noob question regarding how to architect my iPhone app. I have
I have a tool (Enterprise Architect) which can export an Ecore file. I want
I have created a simple state machine model in Enterprise Architect and exported it
On my machine I have Visual Studio 2008,C# Express,Delphi 7 and Delphi 2009 Architect(No
I have a User entity which has a HasCompletedSecurity property which indicates whether that
This is more of a architect question rather than one that requires code. 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.