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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:21:33+00:00 2026-05-14T07:21:33+00:00

I have a tree view defined as follows: <HierarchicalDataTemplate x:Key=ChildTemplate ItemsSource={Binding Children}> <TextBlock Text={Binding

  • 0

I have a tree view defined as follows:

<HierarchicalDataTemplate x:Key="ChildTemplate"
                          ItemsSource="{Binding Children}">
    <TextBlock Text="{Binding TagName, Mode=OneWay}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="NavigationHeaderTemplate"
                          ItemsSource="{Binding Children}"
                          ItemTemplate="{StaticResource ChildTemplate}">
    <StackPanel Orientation="Horizontal" Margin="0">
        <Image Source="{Binding Image}" Height="16" Width="16"></Image>
        <TextBlock Text="{Binding Header}"></TextBlock>
    </StackPanel>
</HierarchicalDataTemplate>
<TreeView Grid.Row="0" Grid.Column="0" Margin="0"
    FlowDirection="LeftToRight"
    ItemTemplate="{StaticResource NavigationHeaderTemplate}"
    Name="TreeView2">
</TreeView>

The data binding is:

public class ViewTag : INotifyPropertyChanged
{
    private string _tagName;
    public string TagName
    {
        get { return _tagName; }
        set
        {
            _tagName = value;
            PropertyChanged(this, new PropertyChangedEventArgs("Tag Name"));
        }
    }
    private ObservableCollection<ViewTag> _childTags;
    public ObservableCollection<ViewTag> ChildTags
    {
        get { return _childTags; }
        set
        {
            _childTags = value;
            OnPropertyChanged(new PropertyChangedEventArgs("Child Tags"));
        }
    }

    #region INotifyPropertyChanged Members

    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, e);
    }
    #endregion

    public ViewTag(string tagName, ObservableCollection<ViewTag> childTags)
    {
        _tagName = tagName;
        _childTags = childTags;
    }
}

public class ViewNavigationTree
{
    public string Image { get; set; }
    public string Header { get; set; }
    public ObservableCollection<ViewTag> Children { get; set; }
}

And my test binding is:

        var xy = new List<ViewNavigationTree>();
        List<ViewTag> tempTags = new List<ViewTag>();
        ViewTag t1, t2, t3, t4, t5, t6;
        t1 = new ViewTag("Computers", null);
        t2 = new ViewTag("Chemistry", null);
        t3 = new ViewTag("Physics", null);
        var t123 = new ObservableCollection<ViewTag>();
        t123.Add(t1);
        t123.Add(t2);
        t123.Add(t3);
        t4 = new ViewTag("Science", t123);
        var t1234 = new ObservableCollection<ViewTag>();
        t1234.Add(t4);
        t5 = new ViewTag("All Items", t1234);
        t6 = new ViewTag("Untagged", null);

        var tall = new ObservableCollection<ViewTag>();
        tall.Add(t5);
        tall.Add(t6);
        xy.Add(new ViewNavigationTree() { Header = "Tags", Image = "img/tags2.ico", Children = tall });

        var rootFolders = eDataAccessLayer.RepositoryFacrory.Instance.MonitoredDirectoriesRepository.Directories.ToList();
        var viewFolders = new ObservableCollection<ViewTag>();
        foreach (var vf in rootFolders)
        {
            viewFolders.Add(new ViewTag(vf.FullPath, null));
        }
        xy.Add(new ViewNavigationTree() { Header = "Folders", Image = "img/folder_16x16.png", Children = viewFolders });

        xy.Add(new ViewNavigationTree() { Header = "Authors", Image = "img/user_16x16.png", Children = null });
        xy.Add(new ViewNavigationTree() { Header = "Publishers", Image = "img/powerplant_32.png", Children = null });

        TreeView2.ItemsSource = xy;

Problem is, the tree only shows:

+ Tags
    All Items
    Untagged
+ Folders
    dir 1
    dir 2
    ...
Authors
Publishers

The items I added under “All Items” aren’t displayed.

Being a WPF nub, i can’t put my finger on the problem. Any help will be greatly appriciated.

  • 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-14T07:21:33+00:00Added an answer on May 14, 2026 at 7:21 am

    The only thing that jumps out here is that you’re referencing the Children property in your ChildTemplate instead of ChildTags as defined in ViewTag.

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

Sidebar

Related Questions

I want to implememt a tree view with has the following structure..... [RootNode] <----
I have a rather large tree grid of clients (total tree size 3000 but
I wonder how I can manipulate the DOM tree using PHP? I have seen
I have a treeview with a fixed size. How can i make it scrollable
I have three Buttons , one TextBox and a TreeView . I am adding
I want to create a hierarchical view of strings based on first two characters.
I have a simple requirement (perhaps hypothetical): I want to store english word dictionary
I'm trying to build a tree of LI/UL elements from an interal object I
I am trying to do the typical thing where you load data into a
i am new with Nodes here.. :) i came up with this algorithm but

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.