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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:35:34+00:00 2026-05-23T03:35:34+00:00

I have an application that reads database tables and puts it into a treeview.

  • 0

I have an application that reads database tables and puts it into a treeview. The current ItemTemplate for the treeview looks like this:

<TreeView.ItemTemplate>
    <HierarchicalDataTemplate ItemsSource="{Binding SubOrganLocations}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="35" />
                <ColumnDefinition Width="35" />
                <ColumnDefinition Width="35" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Text="{Binding OrganDisplayName}" />
            <TextBox Grid.Column="1" IsEnabled="True" />
            <TextBox Grid.Column="2" IsEnabled="True" />
            <TextBox Grid.Column="3" IsEnabled="True" />
        </Grid>
    </HierarchicalDataTemplate>
</TreeView.ItemTemplate>

However, in the future there could be more columns that need to be added (determined by the number of distinct values in a table), so I’m trying to create it dynamically. How would I go about doing that?

  • 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-23T03:35:35+00:00Added an answer on May 23, 2026 at 3:35 am

    Something like this might be possible:

    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding SubOrganLocations}">
            <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding OrganDisplayName}" />
    
                    <!-- If the fields to bind to can be exposed via a collection:
                    <ItemsControl ItemsSource="{Binding Fields}"> -->
                    <ItemsControl ItemsSource="{Binding, Converter={StaticResource SomeCleverConverter}}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding Value}" Width="35" />
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
    
                </StackPanel>
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
    

    It depends if the DataContext of the TreeViewItem (the SubOrganLocation) can expose a collection of fields, or at least be used to derive them with a converter. The simplest and probably easiest would be to expose a collection of fields so you can just do {Binding Fields}.

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

Sidebar

Related Questions

I have an application that reads a table from a database. I issue an
I have an application that reads a database and outputs alerts to any dependencies
I have an application in mind which dicates database tables be append-only; that is,
I have an application that reads records from the database and exports it out
I have an application that reads the structure of an existing PostgreSQL 9.1 database,
In the database, I have a definition table that is read from the application
I have an application that reads a CSV file with piles of data rows.
I have an application that reads lines from a file and runs its magic
I have an application that reads data from a com port using javax.comm. The
I have an iPhone application that reads RSS feeds from a YouTube channel. However,

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.