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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:43:49+00:00 2026-05-31T22:43:49+00:00

I try to implement HierarchicalDataTemplate for the self referencing table in Silverlight 4. It

  • 0

I try to implement HierarchicalDataTemplate for the self referencing table in Silverlight 4.

enter image description here

It shows all items in the TreeView like 1 level instead of the hierarchical view. It should be 3 levels of the items.

enter image description here

So I got stuck how to do it… Any clue? Thank you!

<UserControl x:Class="TreeViewCRUD.MainPage"
 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"             
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Crud="clr-namespace:TreeViewCRUD"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid>
           <sdk:TreeView Height="403" Margin="0,0,0,0"  Name="TreeView1" Background="Beige" >
        <sdk:TreeView.ItemTemplate>
            <sdk:HierarchicalDataTemplate ItemsSource="{Binding Divisions}" >
                <TextBlock Text="{Binding Name, Mode=OneWay}" Margin="5,0"></TextBlock>
           </sdk:HierarchicalDataTemplate>                
        </sdk:TreeView.ItemTemplate>
    </sdk:TreeView>
    </Grid>
</UserControl>

and C#

 void client_GetDivisionsCompleted(object sender, MyService.GetDivisionsCompletedEventArgs e)
        {
            var lst = e.Result;
            try
            {
                TreeView1.DataContext = lst;
                // TreeView1.ItemsSource = lst;
                TreeView1.ItemsSource =  lst.Where(a=>a.DivisionID != null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                MessageBox.Show(ex.StackTrace.ToString());
            }
        }
  • 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-31T22:43:50+00:00Added an answer on May 31, 2026 at 10:43 pm

    I suspect that your XAML is correct(mostly) and the data is the issue. I assume lst contains some data like

    ID    DivisionID  Divisions1
    1     null        (List<Division>)
    2     1           (List<Division>)
    3     2           (List<Division>)
    

    When what you really need lst to be is

    ID    DivisionID  Divisions1
    1     null        (List<Division>)
    

    Now lst[0].Divisions1 would be

    ID    DivisionID  Divisions1
    2     1           (List<Division>)
    

    And finally lst[0].Divisions1[0].Divisions1 would be

    ID    DivisionID  Divisions1
    3     2           (List<Division>)
    

    Verify that the data from WCF is coming with the Navigation Properties intact. Even if lst shows all 3 elements instead just the top level one, you should be able to filter that down client side.

    The last thing I noticed is that you are using ItemsSource="{Binding Divisions}" for your binding. However, in the class diagram, the properties name is Divisions1

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

Sidebar

Related Questions

I would like to implement an B+ tree in Java and try to optimize
i try to implement panning and zooming functionality like safari browser in ipad. i
I try to implement point lights in OpenGL with GLSL. I send all the
I try to implement callback interface with COM techonlogy and have IDL like that:
hi we try to implement a process like when a user does something, his
I try to implement the abstract DbCommand class (like OdbcCommand, OleDbCommand, ...) but a
When I try to implement the below code: $('.touchelement').bind({'touchstart':function(e){ console.info(e.touches.item(0)); }}); It shows the
I try to implement a table function by following Tony Andrews example . But
I'd like to try and implement some HCI for my existing OpenGL application. If
I try to implement basic data feed example and all I get is just:

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.