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

  • Home
  • SEARCH
  • 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 707379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:16:16+00:00 2026-05-14T04:16:16+00:00

Could you tell me why I can’t see subItems? I’ve got winforms apps and

  • 0

Could you tell me why I can’t see subItems?

I’ve got winforms apps and I added my wpfusercontrol:ObjectsAndZonesTree

ServiceProvider is my webservice. Adn method to get listofcountires with subitems works properly (i get countires, regions from this countires, provinces etc…)

 ElementHost elementHost = new ElementHost
                                          {
                                              Width = 150,
                                              Height = 50,
                                              Dock = DockStyle.Fill,
                                              Child = new ObjectsAndZonesTree()
                                          };


            this.splitContainer3.Panel1.Controls.Add(elementHost);

XAML:

<TreeView Name="GroupView" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding}">
        <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type ServiceProvider:Country
}" ItemsSource="{Binding Items}">
                <TextBlock Text="{Binding Path=Name}" />
                </HierarchicalDataTemplate>
            <DataTemplate DataType="{x:Type ServiceProvider:Region}" >
                <TextBlock Text="{Binding Path=Name}" />
                </DataTemplate>
            <DataTemplate DataType="{x:Type ServiceProvider:Province}" >
                <TextBlock Text="{Binding Path=Name}" />
                </DataTemplate>
        </TreeView.Resources>
    </TreeView>

XAML.CS

 public ObjectsAndZonesTree()
        {
            InitializeComponent();

            LoadView();
        }

        private void LoadView()
        {
            GroupView.ItemsSource = new ServiceProvider().GetListOfObjectsAndZones();

        }

class Country:

public class Country
    {
        string _name;

        [XmlAttribute]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        string _code;

        [XmlAttribute]
        public string Code
        {
            get { return _code; }
            set { _code = value; }
        }

        string _continentCode;

        [XmlAttribute]
        public string ContinentCode
        {
            get { return _continentCode; }
            set { _continentCode = value; }
        }

        public Region[] ListOfRegions
        {
            get { return _listOfRegions; }
            set { _listOfRegions = value; }
        }

        private Region[] _listOfRegions;

        public IList<object> Items
        {
            get
            {
                IList<object> childNodes = new List<object>();
                foreach (var group in this.ListOfRegions)
                    childNodes.Add(group);

                return childNodes;
            }
        }



    }

Class Region:

public class Region
{

private Province[] _listOfProvinces;
        private string _name;
        private string _code;

        public Province[] ListOfProvinces
        {
            get { return _listOfProvinces; }
            set { _listOfProvinces = value; }
        }

        public string Name
        {
            get {
                return _name;
            }
            set {
                _name = value;
            }
        }

        public string Code
        {
            get {
                return _code;
            }
            set {
                _code = value;
            }
        }

        public string CountryCode
        {
            get { return _countryCode; }
            set { _countryCode = value; }
        }

        private string _countryCode;

        public IList<object> Items
        {
            get
            {
                IList<object> childNodes = new List<object>();
                foreach (var group in this.ListOfProvinces)
                    childNodes.Add(group);

                return childNodes;
            }
        }
}

It displays me only list of countires.

  • 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-14T04:16:16+00:00Added an answer on May 14, 2026 at 4:16 am

    Your Region DataTemplate needs to be a HierarchicalDataTemplate to support nested items (SubItems). You also need to specify it’s ItemsSource.

    <TreeView Name="GroupView" Grid.Row="0" Grid.Column="0" ItemsSource="{Binding}">
        <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type ServiceProvider:Country}"
                                      ItemsSource="{Binding Items}">
                <TextBlock Text="{Binding Path=Name}" />
            </HierarchicalDataTemplate>
            <HierarchicalDataTemplate DataType="{x:Type ServiceProvider:Region}" 
                                      ItemsSource="{Binding Items}">
                <TextBlock Text="{Binding Path=Name}" />
            </HierarchicalDataTemplate>
            <DataTemplate DataType="{x:Type ServiceProvider:Province}">
                <TextBlock Text="{Binding Path=Name}" />
            </DataTemplate>
        </TreeView.Resources>
    </TreeView>
    

    So for example if you add Cities to your Provinces the changes in your XAML might look something like this.

            <HierarchicalDataTemplate DataType="{x:Type ServiceProvider:Province}" 
                                      ItemsSource="{Binding Cities}">
                <TextBlock Text="{Binding Path=Name}" />
            </HierarchicalDataTemplate>
    
            <DataTemplate DataType="{x:Type ServiceProvider:City}">
                <TextBlock Text="{Binding Path=Name}" />
            </DataTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone can tell me where I can find full ASP.NET MVC beta documentation?
Could someone please tell me which objects types can be tested using Regular Expressions
Could somebody tell me how can I remove input filter chooser from comment form
I would appreciate it if you could tell me how I can convert hexadecimal
Could someone tell me what the units the SetTimeout(int) method in the ICriteria interface
Could you tell me how to translate the following SQL code to Linq To
Could someone tell me why the SSRS web service ReportService2005.asmx has a recursive parameter
Could someone tell me how the field Task Group is used in standard SharePoint
Could some one tell me how to capture SOAP messages passed between the client
Could somebody please tell me what is Memory Page Out Rate. I have seen

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.