I am trying to create a TreeView
that allows child nodes of types textBlock
and comboBox
. Here is a picture of what this would look like:
I believe that this is an issue that can be solved by using a HierarchicalDataTemplate
because the xaml is the area of the code that I would specify what UI control I cam using. So far I have tried implementing a StackPanel
with my HierarchicalDataTemplate
like so:
<HierarchicalDataTemplate DataType="{x:Type data:DataModel}" ItemsSource="{Binding Children}">
<StackPanel>
<TextBlock Text="{Binding DisplayName}" />
<ComboBox ItemsSource="{Binding CommandCollection}" />
</StackPanel>
</HierarchicalDataTemplate>
But I do not achieve the correct solution with this because StackPanel
is basically setting up each node so that they contain both a textBlock
and a comboBox
. This is a problem because each child node is either a textBlock
or a comboBox
, never both. How do I set up a HierarchicalDataTemplate
that allows TreeView
child nodes to be either textBlocks
or comboBoxes
? Please let me know if you would like more details on how my TreeView
is implemented, or would like to see more code.
Some background references to this question can be found here, and here.