Click here to Skip to main content
13,088,507 members (53,898 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to bind a list to a treeview, but currently i can only get the First item in the list to show in my treeview

I have a Person class with 4 string items in it.

I'm binding to a property with a List<person>

My xaml is
<TreeViewItem Header="People">
<TextBlock Text={Binding GetPersons/FirstName}/>
<TextBlock Text={Binding GetPersons/LastName}/>

I've tried adding the itemsSource at the Treeview level, but i don't think my syntax is correct.

Result i'm looking for is that on root expand i have 4 entries.
Posted 25-Sep-12 5:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You should take a look at the bottom of this page:[^]
  <treeviewitem header="Employee1">
    <treeviewitem header="Jesper" />
    <treeviewitem header="Aaberg" />
    <treeviewitem header="12345" />
 <treeviewitem header="Employee2">
    <treeviewitem header="Dominik" />
    <treeviewitem header="Paiha" />
    <treeviewitem header="98765" />

To use a text box I do something like:
        <TextBlock Text={Binding GetPersons/FirstName}/>
Sergey Alexandrovich Kryukov 25-Sep-12 15:20pm
That's it, a 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100