1

I have a treeview that is bound to a database table. Each treeview item will be a grid that will have in it's first column a display name, and then a variable amount of columns containing a text box (This will depend on the amount of distinct values found in one of the columns). I've heard that a custom control would be a good choice to accomplish this, but even after looking at some tutorials online I'm having a hard time figuring out where to start with this.

Thanks!

Saggio
  • 2,212
  • 6
  • 33
  • 50
  • I'm assuming this is related to [your other question](http://stackoverflow.com/questions/6140783/wpf-programmatically-create-treeview-itemtemplate-columns). Instead of a Grid, I would use an ItemsControl, but that requires that the TreeViewItem's DataContext (a SubOrganLocation?) can provide an enumerable of some sort. Can you give more info about the object the TreeViewItem is bound to? – default.kramer Jun 10 '11 at 18:53
  • @default.kramer Yes, this question is somewhat related. SubOrganLocations is an ObservableCollection of objects with 4 fields (3 strings, 1 other object with 4 additional fields - 1 int, 3 strings) – Saggio Jun 10 '11 at 19:33

2 Answers2

1

Found out how to get it done! WPF Programmatically create treeview itemtemplate/columns

Community
  • 1
  • 1
Saggio
  • 2,212
  • 6
  • 33
  • 50
0

You should first use HierarchicalDataTemplate like this:

<HierarchicalDataTemplate ItemsSource="{Binding YourDataTimeChildNodes}" DataType="{x:Type YourDataType}">
    <Grid>
          <TextBlock Text={Binding YourData}/>
          <TextBox Text={Binding YourData2}/>
          And other stuff
    </Grid>
</HierarchicalDataTemplate>
Navid Rahmani
  • 7,848
  • 9
  • 39
  • 57