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!

2
  • I'm assuming this is related to your other question. 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? Commented Jun 10, 2011 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) Commented Jun 10, 2011 at 19:33

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.