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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:12:38+00:00 2026-06-12T06:12:38+00:00

just starting with wpf. I need to bind the object (Hierarchical) Folder public class

  • 0

just starting with wpf.
I need to bind the object (Hierarchical) Folder

public class Folder
{
    public Folder()
    {
        this.Name = string.Empty;
        this.Modules = new ObservableCollection<Module>();
        this.Folders = new List<Folder>();
        this.HasChild = false;
    }

    public Folder(Folder parent)
    {
        this.Name = string.Empty;
        this.Modules = new ObservableCollection<Module>();
        this.Folders = new List<Folder>();
        this.HasChild = false;
        this.Parent = parent;
    }

    public bool HasChild { get; set; }

    public string Name { get; set; }

    public List<Folder> Folders { get; set; }

    public ObservableCollection<Module> Modules { get; set; }

    public Folder Parent { get; set; }

    public Folder IfItemExists(string name)
    {
        foreach (Folder folder in Folders)
        {
            if (folder.Name == name)
            {
                return folder;
            }
        }

        return null;
    }
}

to the treeview. I am doing like that

   <TreeView Name="treeView" Margin="5">
        <TreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}" DataType="{x:Type ModulesUpToDateChecker:Folder}">
                <HierarchicalDataTemplate.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=Name}"></TextBlock>
                    </DataTemplate>
                </HierarchicalDataTemplate.ItemTemplate>
            </HierarchicalDataTemplate>
        </TreeView.ItemTemplate>
    </TreeView>

and have just empty docpanel. The object is filled write. Eche child has own child with the same Type.

  • 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-06-12T06:12:40+00:00Added an answer on June 12, 2026 at 6:12 am

    A HierarchicalDataTemplate is already a DataTemplate (it derives from it). So just skip the ItemTemplate and DataTemplate stuff inside your HierarchicalDataTemplate like so:

    <TreeView Name="treeView" Margin="5">
      <TreeView.Resources>
        <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}" DataType="{x:Type WpfApplication220:Folder}">
          <TextBlock Text="{Binding Path=Name}"></TextBlock>
        </HierarchicalDataTemplate>
      </TreeView.Resources>
    </TreeView>
    

    Oh and you have to set the ItemsSource of your treeview either programmatically or in your markup ..

    treeView.ItemsSource = ..yourFolderList..
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be simple for you guys but am just starting in WPF, and
Just starting out in Unix and need t workout this:- I have a csv
Just starting so any facilitation appreciated. Have an object serialized it to this starting
I'm just starting out with WPF and need some help with routed events. I
I am just starting with WPF and I have this ListBox that displays an
Just starting out, this should be a simple one but I haven't been able
I'm just starting WPF so am just learning but I've ran into a problem
I'm just starting out with WPF and I'm trying to layout a UI. I
I am just starting out using IronPython with WPF and I don't quiet understand
I'm just starting to work with Silverlight (no WPF experience either) and am having

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.