Creating WPF Grid Dynamically
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 con开发者_如何学JAVAtaining 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!
Found out how to get it done! WPF Programmatically create treeview itemtemplate/columns
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>
精彩评论